vmxnet3: make descriptor count checks more robust
[freebsd.git] / secure / lib / libcrypto / man / man3 / ERR_put_error.3
1 .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
72 .    \" fudge factors for nroff and troff
73 .if n \{\
74 .    ds #H 0
75 .    ds #V .8m
76 .    ds #F .3m
77 .    ds #[ \f1
78 .    ds #] \fP
79 .\}
80 .if t \{\
81 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
82 .    ds #V .6m
83 .    ds #F 0
84 .    ds #[ \&
85 .    ds #] \&
86 .\}
87 .    \" simple accents for nroff and troff
88 .if n \{\
89 .    ds ' \&
90 .    ds ` \&
91 .    ds ^ \&
92 .    ds , \&
93 .    ds ~ ~
94 .    ds /
95 .\}
96 .if t \{\
97 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
98 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
99 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
100 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
101 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
102 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
103 .\}
104 .    \" troff and (daisy-wheel) nroff accents
105 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
106 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
107 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
108 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
109 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
110 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
111 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
112 .ds ae a\h'-(\w'a'u*4/10)'e
113 .ds Ae A\h'-(\w'A'u*4/10)'E
114 .    \" corrections for vroff
115 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
116 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
117 .    \" for low resolution devices (crt and lpr)
118 .if \n(.H>23 .if \n(.V>19 \
119 \{\
120 .    ds : e
121 .    ds 8 ss
122 .    ds o a
123 .    ds d- d\h'-1'\(ga
124 .    ds D- D\h'-1'\(hy
125 .    ds th \o'bp'
126 .    ds Th \o'LP'
127 .    ds ae ae
128 .    ds Ae AE
129 .\}
130 .rm #[ #] #H #V #F C
131 .\" ========================================================================
132 .\"
133 .IX Title "ERR_PUT_ERROR 3ossl"
134 .TH ERR_PUT_ERROR 3ossl "2023-09-19" "3.0.11" "OpenSSL"
135 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
136 .\" way too many mistakes in technical documents.
137 .if n .ad l
138 .nh
139 .SH "NAME"
140 ERR_raise, ERR_raise_data,
141 ERR_put_error, ERR_add_error_data, ERR_add_error_vdata,
142 ERR_add_error_txt, ERR_add_error_mem_bio
143 \&\- record an error
144 .SH "SYNOPSIS"
145 .IX Header "SYNOPSIS"
146 .Vb 1
147 \& #include <openssl/err.h>
148 \&
149 \& void ERR_raise(int lib, int reason);
150 \& void ERR_raise_data(int lib, int reason, const char *fmt, ...);
151 \&
152 \& void ERR_add_error_data(int num, ...);
153 \& void ERR_add_error_vdata(int num, va_list arg);
154 \& void ERR_add_error_txt(const char *sep, const char *txt);
155 \& void ERR_add_error_mem_bio(const char *sep, BIO *bio);
156 .Ve
157 .PP
158 The following function has been deprecated since OpenSSL 3.0, and can be
159 hidden entirely by defining \fB\s-1OPENSSL_API_COMPAT\s0\fR with a suitable version value,
160 see \fBopenssl_user_macros\fR\|(7):
161 .PP
162 .Vb 1
163 \& void ERR_put_error(int lib, int func, int reason, const char *file, int line);
164 .Ve
165 .SH "DESCRIPTION"
166 .IX Header "DESCRIPTION"
167 \&\fBERR_raise()\fR adds a new error to the thread's error queue.  The
168 error occurred in the library \fBlib\fR for the reason given by the
169 \&\fBreason\fR code.  Furthermore, the name of the file, the line, and name
170 of the function where the error occurred is saved with the error
171 record.
172 .PP
173 \&\fBERR_raise_data()\fR does the same thing as \fBERR_raise()\fR, but also lets the
174 caller specify additional information as a format string \fBfmt\fR and an
175 arbitrary number of values, which are processed with \fBBIO_snprintf\fR\|(3).
176 .PP
177 \&\fBERR_put_error()\fR adds an error code to the thread's error queue. It
178 signals that the error of reason code \fBreason\fR occurred in function
179 \&\fBfunc\fR of library \fBlib\fR, in line number \fBline\fR of \fBfile\fR.
180 This function is usually called by a macro.
181 .PP
182 \&\fBERR_add_error_data()\fR associates the concatenation of its \fBnum\fR string
183 arguments as additional data with the error code added last.
184 \&\fBERR_add_error_vdata()\fR is similar except the argument is a \fBva_list\fR.
185 Multiple calls to these functions append to the current top of the error queue.
186 The total length of the string data per error is limited to 4096 characters.
187 .PP
188 \&\fBERR_add_error_txt()\fR appends the given text string as additional data to the
189 last error queue entry, after inserting the optional separator string if it is
190 not \s-1NULL\s0 and the top error entry does not yet have additional data.
191 In case the separator is at the end of the text it is not appended to the data.
192 The \fBsep\fR argument may be for instance \*(L"\en\*(R" to insert a line break when needed.
193 If the associated data would become more than 4096 characters long
194 (which is the limit given above)
195 it is split over sufficiently many new copies of the last error queue entry.
196 .PP
197 \&\fBERR_add_error_mem_bio()\fR is the same as \fBERR_add_error_txt()\fR except that
198 the text string is taken from the given memory \s-1BIO.\s0
199 It appends '\e0' to the \s-1BIO\s0 contents if not already NUL-terminated.
200 .PP
201 \&\fBERR_load_strings\fR\|(3) can be used to register
202 error strings so that the application can a generate human-readable
203 error messages for the error code.
204 .SS "Reporting errors"
205 .IX Subsection "Reporting errors"
206 \fIOpenSSL library reports\fR
207 .IX Subsection "OpenSSL library reports"
208 .PP
209 Each OpenSSL sub-library has library code \fB\s-1ERR_LIB_XXX\s0\fR and has its own set
210 of reason codes \fB\s-1XXX_R_...\s0\fR.  These are both passed in combination to
211 \&\fBERR_raise()\fR and \fBERR_raise_data()\fR, and the combination ultimately produces
212 the correct error text for the reported error.
213 .PP
214 All these macros and the numbers they have as values are specific to
215 OpenSSL's libraries.  OpenSSL reason codes normally consist of textual error
216 descriptions. For example, the function \fBssl3_read_bytes()\fR reports a
217 \&\*(L"handshake failure\*(R" as follows:
218 .PP
219 .Vb 1
220 \& ERR_raise(ERR_LIB_SSL, SSL_R_SSL_HANDSHAKE_FAILURE);
221 .Ve
222 .PP
223 There are two exceptions:
224 .IP "\fB\s-1ERR_LIB_SYS\s0\fR" 4
225 .IX Item "ERR_LIB_SYS"
226 This \*(L"library code\*(R" indicates that a system error is being reported.  In
227 this case, the reason code given to \fBERR_raise()\fR and \fBERR_raise_data()\fR \fImust\fR
228 be \fBerrno\fR\|(3).
229 .Sp
230 .Vb 1
231 \& ERR_raise(ERR_LIB_SYS, errno);
232 .Ve
233 .IP "\fB\s-1ERR_R_XXX\s0\fR" 4
234 .IX Item "ERR_R_XXX"
235 This set of error codes is considered global, and may be used in combination
236 with any sub-library code.
237 .Sp
238 .Vb 1
239 \& ERR_raise(ERR_LIB_RSA, ERR_R_PASSED_INVALID_ARGUMENT);
240 .Ve
241 .PP
242 \fIOther pieces of software\fR
243 .IX Subsection "Other pieces of software"
244 .PP
245 Other pieces of software that may want to use OpenSSL's error reporting
246 system, such as engines or applications, must normally get their own
247 numbers.
248 .IP "\(bu" 4
249 To get a \*(L"library\*(R" code, call \fBERR_get_next_error_library\fR\|(3); this gives
250 the calling code a dynamic number, usable for the duration of the process.
251 .IP "\(bu" 4
252 Reason codes for each such \*(L"library\*(R" are determined or generated by the
253 authors of that code.  They must be numbers in the range 1 to 524287 (in
254 other words, they must be nonzero unsigned 18 bit integers).
255 .PP
256 The exceptions mentioned in \*(L"OpenSSL library reports\*(R" above are valid for
257 other pieces of software, i.e. they may use \fB\s-1ERR_LIB_SYS\s0\fR to report system
258 errors:
259 .PP
260 .Vb 1
261 \& ERR_raise(ERR_LIB_SYS, errno);
262 .Ve
263 .PP
264 \&... and they may use \fB\s-1ERR_R_XXX\s0\fR macros together with their own \*(L"library\*(R"
265 code.
266 .PP
267 .Vb 1
268 \& int app_lib_code = ERR_get_next_error_library();
269 \&
270 \& /* ... */
271 \&
272 \& ERR_raise(app_lib_code, ERR_R_PASSED_INVALID_ARGUMENT);
273 .Ve
274 .SH "RETURN VALUES"
275 .IX Header "RETURN VALUES"
276 \&\fBERR_raise()\fR, \fBERR_raise_data()\fR, \fBERR_put_error()\fR,
277 \&\fBERR_add_error_data()\fR, \fBERR_add_error_vdata()\fR
278 \&\fBERR_add_error_txt()\fR, and \fBERR_add_error_mem_bio()\fR
279 return no values.
280 .SH "NOTES"
281 .IX Header "NOTES"
282 \&\fBERR_raise()\fR, \fBERR_raise()\fR and \fBERR_put_error()\fR are implemented as macros.
283 .SH "SEE ALSO"
284 .IX Header "SEE ALSO"
285 \&\fBERR_load_strings\fR\|(3), \fBERR_get_next_error_library\fR\|(3)
286 .SH "HISTORY"
287 .IX Header "HISTORY"
288 ERR_raise, ERR_raise_data, \fBERR_add_error_txt()\fR and \fBERR_add_error_mem_bio()\fR
289 were added in OpenSSL 3.0.
290 .SH "COPYRIGHT"
291 .IX Header "COPYRIGHT"
292 Copyright 2000\-2021 The OpenSSL Project Authors. All Rights Reserved.
293 .PP
294 Licensed under the Apache License 2.0 (the \*(L"License\*(R").  You may not use
295 this file except in compliance with the License.  You can obtain a copy
296 in the file \s-1LICENSE\s0 in the source distribution or at
297 <https://www.openssl.org/source/license.html>.