include/openssl/err.h: Depend on OPENSSL_NO_FILENAMES, not OPENSSL_NO_ERR
authorRichard Levitte <levitte@openssl.org>
Wed, 4 Sep 2019 19:55:58 +0000 (21:55 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 12 Sep 2019 15:59:52 +0000 (17:59 +0200)
The configuration option 'no-err' is documented to be used to avoid
loading error related string tables.  For some reason, it was also
used to define if ERR_PUT_error() would pass the source file name and
line information or not.

The configuration option 'no-filenames' is documented to be used to
avoid passing the source file name and line anywhere.  So, the
definition of ERR_PUT_error() should depend on OPENSSL_NO_FILENAMES
rather than OPENSSL_NO_ERR.

Furthermore, the definition of OPENSSL_FILE and OPENSSL_LINE depends
on if OPENSSL_NO_FILENAMES is defined or not, so there was never any
need to do extra macro gymnastics in include/openssl/err.h, so we
simply remove it and use OPENSSL_FILE and OPENSSL_LINE directly.

Finally, the macro OPENSSL_FUNC is unaffected by all these
configuration options, so it should be used in all macros that call
ERR_set_debug().

Fixes #9756

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9756)

include/openssl/err.h

index 03c3593f3404125d0d389c6d957d0f6e06d92780..0da66092b4d68b16d00a25a8b64e60c7f308addb 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #endif
 
 # if !OPENSSL_API_3
-#  ifndef OPENSSL_NO_ERR
+#  ifndef OPENSSL_NO_FILENAMES
 #   define ERR_PUT_error(l,f,r,fn,ln)      ERR_put_error(l,f,r,fn,ln)
 #  else
 #   define ERR_PUT_error(l,f,r,fn,ln)      ERR_put_error(l,f,r,NULL,0)
@@ -242,28 +242,18 @@ void ERR_set_debug(const char *file, int line, const char *func);
 void ERR_set_error(int lib, int reason, const char *fmt, ...);
 void ERR_vset_error(int lib, int reason, const char *fmt, va_list args);
 
-# ifndef OPENSSL_NO_ERR
-#  define ERR_DBG_FILE OPENSSL_FILE
-#  define ERR_DBG_LINE OPENSSL_LINE
-#  define ERR_DBG_FUNC OPENSSL_FUNC
-# else
-#  define ERR_DBG_FILE NULL
-#  define ERR_DBG_LINE 0
-#  define ERR_DBG_FUNC NULL
-# endif
-
 /* Main error raising functions */
 # define ERR_raise(lib, reason) ERR_raise_data((lib),(reason),NULL)
 # define ERR_raise_data                                         \
     (ERR_new(),                                                 \
-     ERR_set_debug(ERR_DBG_FILE,ERR_DBG_LINE,ERR_DBG_FUNC),     \
+     ERR_set_debug(OPENSSL_FILE,OPENSSL_LINE,OPENSSL_FUNC),     \
      ERR_set_error)
 
 # if !OPENSSL_API_3
 /* Backward compatibility */
 #  define ERR_put_error(lib, func, reason, file, line)          \
     (ERR_new(),                                                 \
-     ERR_set_debug((file), (line), NULL),                       \
+     ERR_set_debug((file), (line), OPENSSL_FUNC),               \
      ERR_set_error((lib), (reason), NULL))
 # endif