/* ERR_get_error_line_data acts like |ERR_get_error_line|, but also returns the
* error-specific data pointer and flags. The flags are a bitwise-OR of
- * |ERR_FLAG_*| values. */
+ * |ERR_FLAG_*| values. The error-specific data is owned by the error queue
+ * and the pointer becomes invalid after the next call that affects the same
+ * thread's error queue. If |*flags| contains |ERR_FLAG_STRING| then |*data| is
+ * human-readable. */
OPENSSL_EXPORT uint32_t ERR_get_error_line_data(const char **file, int *line,
- char **data, int *flags);
+ const char **data, int *flags);
/* The "peek" functions act like the |ERR_get_error| functions, above, but they
* do not remove the error from the queue. */
uint8_t flags;
};
-/* ERR_FLAG_MALLOCED means the the |data| member must be freed when no longer
- * needed. */
-#define ERR_FLAG_MALLOCED 1
/* ERR_FLAG_STRING means that the |data| member is a NUL-terminated string that
* can be printed. */
-#define ERR_FLAG_STRING 2
+#define ERR_FLAG_STRING 1
/* ERR_TXT_STRING is provided for compatibility with code that assumes that
* it's using OpenSSL. */
#define ERR_TXT_STRING ERR_FLAG_STRING
/* The following flag values are internal and are masked when flags are
* returned from functions like |ERR_get_error_line_data|. */
+/* ERR_FLAG_MALLOCED means the the |data| member must be freed when no longer
+ * needed. */
+#define ERR_FLAG_MALLOCED 16
/* ERR_FLAG_MARK is used to indicate a reversion point in the queue. See
* |ERR_pop_to_mark|. */
-#define ERR_FLAG_MARK 16
+#define ERR_FLAG_MARK 32
/* ERR_NUM_ERRORS is the limit of the number of errors in the queue. */
#define ERR_NUM_ERRORS 16
unsigned top;
/* bottom contains the index of the last error in the queue. */
unsigned bottom;
+
+ /* to_free, if not NULL, contains a pointer owned by this structure that was
+ * previously a |data| pointer of one of the elements of |errors|. */
+ void *to_free;
} ERR_STATE;
enum {
ERR_LIB_PKCS7,
ERR_LIB_PKCS8,
ERR_LIB_X509V3,
- ERR_LIB_PKCS12,
ERR_LIB_RAND,
ERR_LIB_ENGINE,
ERR_LIB_OCSP,
#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7
#define ERR_R_PKCS8_LIB ERR_LIB_PKCS8
#define ERR_R_X509V3_LIB ERR_LIB_X509V3
-#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12
#define ERR_R_RAND_LIB ERR_LIB_RAND
#define ERR_R_DSO_LIB ERR_LIB_DSO
#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE
(((((uint32_t)lib) & 0xff) << 24) | ((((uint32_t)func) & 0xfff) << 12) | \
((((uint32_t)reason) & 0xfff)))
-#define ERR_GET_LIB(packed_error) (((packed_error) >> 24) & 0xff)
-#define ERR_GET_FUNC(packed_error) (((packed_error) >> 12) & 0xfff)
-#define ERR_GET_REASON(packed_error) ((packed_error) & 0xfff)
+#define ERR_GET_LIB(packed_error) ((int)(((packed_error) >> 24) & 0xff))
+#define ERR_GET_FUNC(packed_error) ((int)(((packed_error) >> 12) & 0xfff))
+#define ERR_GET_REASON(packed_error) ((int)((packed_error) & 0xfff))
/* ERR_STRING_DATA is the type of an lhash node that contains a mapping from a
* library, function or reason code to a string representation of it. */