[exim-dev] [Bug 2507] New: dlerror() incorrectly called twic…

Top Page
Delete this message
Reply to this message
Author: admin
Date:  
To: exim-dev
New-Topics: [exim-dev] [Bug 2507] dlerror() incorrectly called twice thus losing error information in logs, [exim-dev] [Bug 2507] dlerror() incorrectly called twice thus losing error information in logs, [exim-dev] [Bug 2507] dlerror() incorrectly called twice thus losing error information in logs, [exim-dev] [Bug 2507] dlerror() incorrectly called twice thus losing error information in logs
Subject: [exim-dev] [Bug 2507] New: dlerror() incorrectly called twice thus loosing error information in logs
https://bugs.exim.org/show_bug.cgi?id=2507

            Bug ID: 2507
           Summary: dlerror() incorrectly called twice thus loosing error
                    information in logs
           Product: Exim
           Version: 4.93
          Hardware: x86
                OS: All
            Status: NEW
          Severity: bug
          Priority: medium
         Component: General execution
          Assignee: unallocated@???
          Reporter: arekm@???
                CC: exim-dev@???


src/src/drtables.c has:

   741          dl = dlopen(CS big_buffer, RTLD_NOW);// TJ was LAZY
   742          if (dl == NULL) {
   743            fprintf(stderr, "Error loading %s: %s\n", name, dlerror());
   744            moduleerrors++;
   745            log_write(0, LOG_MAIN|LOG_PANIC, "Error loading lookup module
%s: %s\n", name, dlerror());
   746            continue;
   747          }
   748



but calling second dlerror() will return NULL thus loosing information about
error, from manual page:

"If no dynamic linking errors  have  occurred
       since the last invocation of dlerror(), dlerror() shall return NULL. 
Thus, invoking dlerror() a second time, immediately following a prior
invocation, shall result in NULL being returned."


stderr and log:
Error loading sqlite.so: /usr/lib64/exim/modules/sqlite.so: undefined symbol:
sqlite_lock_timeout
2020-01-08 11:07:24 Error loading lookup module sqlite.so: NULL

Fix:

diff --git a/src/src/drtables.c b/src/src/drtables.c
index 059756284..6d8d6bf29 100644
--- a/src/src/drtables.c
+++ b/src/src/drtables.c
@@ -740,9 +740,10 @@ init_lookup_list(void)

         dl = dlopen(CS big_buffer, RTLD_NOW);// TJ was LAZY
         if (dl == NULL) {
-          fprintf(stderr, "Error loading %s: %s\n", name, dlerror());
+          errormsg = dlerror();
+          fprintf(stderr, "Error loading %s: %s\n", name, errormsg);
           moduleerrors++;
-          log_write(0, LOG_MAIN|LOG_PANIC, "Error loading lookup module %s:
%s\n", name, dlerror());
+          log_write(0, LOG_MAIN|LOG_PANIC, "Error loading lookup module %s:
%s\n", name, errormsg);
           continue;
         }



dlclose() also seems to invalidate dlerror result:

stderr and log:
whoson.so does not appear to be a lookup module
(/usr/lib64/exim/modules/whoson.so: undefined symbol: _lookup_module_info)
2020-01-08 11:24:28 whoson.so does not appear to be a lookup module ()



diff --git a/src/src/drtables.c b/src/src/drtables.c
index 059756284..1ab75c2fa 100644
--- a/src/src/drtables.c
+++ b/src/src/drtables.c
@@ -756,9 +757,9 @@ init_lookup_list(void)
         info = (struct lookup_module_info*) dlsym(dl, "_lookup_module_info");
         if ((errormsg = dlerror()) != NULL) {
           fprintf(stderr, "%s does not appear to be a lookup module (%s)\n",
name, errormsg);
-          dlclose(dl);
           moduleerrors++;
           log_write(0, LOG_MAIN|LOG_PANIC, "%s does not appear to be a lookup
module (%s)\n", name, errormsg);
+          dlclose(dl);
           continue;
         }
         if (info->magic != LOOKUP_MODULE_INFO_MAGIC) {


--
You are receiving this mail because:
You are on the CC list for the bug.