]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/err/err_local.h
2 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/err.h>
11 #include <openssl/e_os2.h>
13 static ossl_inline
void err_get_slot(ERR_STATE
*es
)
15 es
->top
= (es
->top
+ 1) % ERR_NUM_ERRORS
;
16 if (es
->top
== es
->bottom
)
17 es
->bottom
= (es
->bottom
+ 1) % ERR_NUM_ERRORS
;
20 static ossl_inline
void err_clear_data(ERR_STATE
*es
, size_t i
, int deall
)
22 if (es
->err_data_flags
[i
] & ERR_TXT_MALLOCED
) {
24 OPENSSL_free(es
->err_data
[i
]);
25 es
->err_data
[i
] = NULL
;
26 es
->err_data_size
[i
] = 0;
27 es
->err_data_flags
[i
] = 0;
28 } else if (es
->err_data
[i
] != NULL
) {
29 es
->err_data
[i
][0] = '\0';
32 es
->err_data
[i
] = NULL
;
33 es
->err_data_size
[i
] = 0;
34 es
->err_data_flags
[i
] = 0;
38 static ossl_inline
void err_set_error(ERR_STATE
*es
, size_t i
,
43 ? (unsigned int)(ERR_SYSTEM_FLAG
| reason
)
44 : ERR_PACK(lib
, 0, reason
);
47 static ossl_inline
void err_set_debug(ERR_STATE
*es
, size_t i
,
48 const char *file
, int line
,
52 * We dup the file and fn strings because they may be provider owned. If the
53 * provider gets unloaded, they may not be valid anymore.
55 OPENSSL_free(es
->err_file
[i
]);
56 if (file
== NULL
|| file
[0] == '\0')
57 es
->err_file
[i
] = NULL
;
59 es
->err_file
[i
] = OPENSSL_strdup(file
);
60 es
->err_line
[i
] = line
;
61 OPENSSL_free(es
->err_func
[i
]);
62 if (fn
== NULL
|| fn
[0] == '\0')
63 es
->err_func
[i
] = NULL
;
65 es
->err_func
[i
] = OPENSSL_strdup(fn
);
68 static ossl_inline
void err_set_data(ERR_STATE
*es
, size_t i
,
69 void *data
, size_t datasz
, int flags
)
71 es
->err_data
[i
] = data
;
72 es
->err_data_size
[i
] = datasz
;
73 es
->err_data_flags
[i
] = flags
;
76 static ossl_inline
void err_clear(ERR_STATE
*es
, size_t i
, int deall
)
78 err_clear_data(es
, i
, (deall
));
81 es
->err_buffer
[i
] = 0;
83 OPENSSL_free(es
->err_file
[i
]);
84 es
->err_file
[i
] = NULL
;
85 OPENSSL_free(es
->err_func
[i
]);
86 es
->err_func
[i
] = NULL
;
89 ERR_STATE
*err_get_state_int(void);
90 void ossl_err_string_int(unsigned long e
, const char *func
,
91 char *buf
, size_t len
);