From: Dr. David von Oheimb Date: Thu, 19 Sep 2019 13:02:50 +0000 (+0200) Subject: Make default values by ERR_get_error_all() and friends more consistent X-Git-Tag: openssl-3.0.0-alpha1~1249 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=df0822688fc3432cf800cdc07c7f9016ea201170;ds=sidebyside Make default values by ERR_get_error_all() and friends more consistent Unset data defaults to the empty string ("") or 0. Reviewed-by: Tomas Mraz Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/9948) --- diff --git a/crypto/err/err.c b/crypto/err/err.c index eca0f6d33e..f46f3bef30 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -533,35 +533,30 @@ static unsigned long get_error_values(ERR_GET_ACTION g, es->err_buffer[i] = 0; } - if (file != NULL && line != NULL) { - if (es->err_file[i] == NULL) { - *file = "NA"; - *line = 0; - } else { - *file = es->err_file[i]; - *line = es->err_line[i]; - } + if (file != NULL) { + *file = es->err_file[i]; + if (*file == NULL) + *file = ""; } - + if (line != NULL) + *line = es->err_line[i]; if (func != NULL) { *func = es->err_func[i]; if (*func == NULL) - *func = "N/A"; + *func = ""; } - + if (flags != NULL) + *flags = es->err_data_flags[i]; if (data == NULL) { if (g == EV_POP) { err_clear_data(es, i, 0); } } else { - if (es->err_data[i] == NULL) { + *data = es->err_data[i]; + if (*data == NULL) { *data = ""; if (flags != NULL) *flags = 0; - } else { - *data = es->err_data[i]; - if (flags != NULL) - *flags = es->err_data_flags[i]; } } return ret; diff --git a/doc/man3/ERR_get_error.pod b/doc/man3/ERR_get_error.pod index 045ef210a2..136b70db46 100644 --- a/doc/man3/ERR_get_error.pod +++ b/doc/man3/ERR_get_error.pod @@ -61,28 +61,35 @@ error queue without modifying it. ERR_peek_last_error() returns the latest error code from the thread's error queue without modifying it. -See L for obtaining information about -location and reason of the error, and -L for human-readable error -messages. +See L for obtaining further specific information +such as the reason of the error, +and L for human-readable error messages. ERR_get_error_line(), ERR_peek_error_line() and ERR_peek_last_error_line() are the same as ERR_get_error(), -ERR_peek_error() and ERR_peek_last_error(), but they +ERR_peek_error() and ERR_peek_last_error(), but on success they additionally store the file name and line number where -the error occurred in *B and *B, unless these are B. +the error occurred in *B and *B, as far as they are not B. +An unset file name is indicated as B<"">, i.e., an empty string. +An unset line number is indicated as B<0>. + +A pointer returned this way by these functions and the ones below +is valid until the respective entry is removed from the error queue. ERR_get_error_func(), ERR_peek_error_func() and ERR_peek_last_error_func() are the same as ERR_get_error(), -ERR_peek_error() and ERR_peek_last_error(), but they -additionally store the name of the function where the error in *B, -unless it is B. +ERR_peek_error() and ERR_peek_last_error(), but on success they +additionally store the name of the function where the error occurred +in *B, unless it is B. +An unset function name is indicated as B<"">. ERR_get_error_data(), ERR_peek_error_data() and ERR_peek_last_error_data() are the same as ERR_get_error(), -ERR_peek_error() and ERR_peek_last_error(), but they +ERR_peek_error() and ERR_peek_last_error(), but on success they additionally store additional data and flags associated with the error -code in *B and *B, unless these are B. +code in *B and *B, as far as they are not B. +Unset data is indicated as B<"">. +In this case the value given for the flag is irrelevant (and equals B<0>). *B contains a string if *B&B is true. ERR_get_error_all(), ERR_peek_error_all() and