]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Swap ERR_get_error_line_data for ERR_get_error_all
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 3 Jan 2022 21:24:30 +0000 (15:24 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 3 Jan 2022 21:24:30 +0000 (15:24 -0600)
src/lib/tls/log.c

index 87478bcfb46a6a35780222d9ecf14f2b35a49968..e25d765eeec5d28d4d98a8e916a4c0f9732dbf3b 100644 (file)
@@ -35,6 +35,17 @@ USES_APPLE_DEPRECATED_API    /* OpenSSL API has been deprecated by Apple */
 #include "log.h"
 #include "utils.h"
 
+#if OPENSSL_VERSION_NUMBER < 0x30000000L
+static inline unsigned long ERR_get_error_all(const char **file, int *line,
+                                             const char **func,
+                                             const char **data, int *flags)
+{
+       if (func != NULL) *func = "";
+
+       return ERR_get_error_line_data(file, line, data, flags);
+}
+#endif
+
 /** Holds the state of a log BIO
  *
  * Most of these fields are expected to change between uses of the BIO.
@@ -226,6 +237,7 @@ static int fr_tls_log_error_va(request_t *request, char const *msg, va_list ap)
 
        int             line;
        char const      *file;
+       char const      *func;
        char const      *data;
        int             flags = 0;
 
@@ -234,7 +246,7 @@ static int fr_tls_log_error_va(request_t *request, char const *msg, va_list ap)
         *      can be used to determine if there are
         *      multiple errors.
         */
-       error = ERR_get_error_line_data(&file, &line, &data, &flags);
+       error = ERR_get_error_all(&file, &line, &func, &data, &flags);
        if (!(flags & ERR_TXT_STRING)) data = NULL;
 
        if (msg) {
@@ -285,7 +297,7 @@ static int fr_tls_log_error_va(request_t *request, char const *msg, va_list ap)
                                  data ? ':' : '\0', data ? data : "");
                }
                in_stack++;
-       } while ((error = ERR_get_error_line_data(&file, &line, &data, &flags)));
+       } while ((error = ERR_get_error_all(&file, &line, &func, &data, &flags)));
 
        return in_stack;
 }
@@ -450,6 +462,7 @@ static int tls_strerror_vasprintf(char const *msg, va_list ap)
 
        int             line;
        char const      *file;
+       char const      *func;
        char const      *data;
        int             flags = 0;
 
@@ -458,7 +471,7 @@ static int tls_strerror_vasprintf(char const *msg, va_list ap)
         *      can be used to determine if there are
         *      multiple errors.
         */
-       error = ERR_get_error_line_data(&file, &line, &data, &flags);
+       error = ERR_get_error_all(&file, &line, &func, &data, &flags);
        if (!(flags & ERR_TXT_STRING)) data = NULL;
 
        if (msg) {
@@ -488,7 +501,7 @@ static int tls_strerror_vasprintf(char const *msg, va_list ap)
                return 0;
        }
 
-       while ((error = ERR_get_error_line_data(&file, &line, &data, &flags))) {
+       while ((error = ERR_get_error_all(&file, &line, &func, &data, &flags))) {
                if (!(flags & ERR_TXT_STRING)) data = NULL;
 
                ERR_error_string_n(error, buffer, sizeof(buffer));