[exim-cvs] Fix error logging for dynamically-loaded modules.…

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] Fix error logging for dynamically-loaded modules. Bug 2507
Gitweb: https://git.exim.org/exim.git/commitdiff/b1c673ddfac7f322a62786cd4aae8b5b30ba69e8
Commit:     b1c673ddfac7f322a62786cd4aae8b5b30ba69e8
Parent:     2fa25efce2a183e8886d66e2f1a0ae83ac964d8e
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Wed Jan 8 10:49:31 2020 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Wed Jan 8 10:52:37 2020 +0000


    Fix error logging for dynamically-loaded modules.  Bug 2507
---
 doc/doc-txt/ChangeLog | 6 +++++-
 src/src/drtables.c    | 5 +++--
 src/src/exim.c        | 6 ++----
 3 files changed, 10 insertions(+), 7 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index ce225e9..2b5b592 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -81,7 +81,11 @@ WB/01 SPF: DNS lookups for the obsolete SPF RR type done by the libspf2 library
       are now specifically given a NO_DATA response without hitting the system
       resolver.  The library goes on to do the now-standard TXT lookup.
       Use of dnsdb lookups is not affected.
-      
+
+JH/19 Bug 2507: Modules: on handling a dynamic-module (lookups) open failure,
+      only retrieve the errormessage once.  Previously two calls to dlerror()
+      were used, and the second one (for mainlog/paniclog) retrieved null
+      information.



Exim version 4.93
diff --git a/src/src/drtables.c b/src/src/drtables.c
index 578ddf3..5583590 100644
--- a/src/src/drtables.c
+++ b/src/src/drtables.c
@@ -753,9 +753,10 @@ else

       if (!(dl = dlopen(CS big_buffer, RTLD_NOW)))
     {
-    fprintf(stderr, "Error loading %s: %s\n", name, dlerror());
+    errormessage = dlerror();
+    fprintf(stderr, "Error loading %s: %s\n", name, errormessage);
     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, errormessage);
     continue;
     }


diff --git a/src/src/exim.c b/src/src/exim.c
index af4b525..92f5623 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -1265,9 +1265,9 @@ void *dlhandle;
void *dlhandle_curses = dlopen("libcurses." DYNLIB_FN_EXT, RTLD_GLOBAL|RTLD_LAZY);

dlhandle = dlopen("libreadline." DYNLIB_FN_EXT, RTLD_GLOBAL|RTLD_NOW);
-if (dlhandle_curses != NULL) dlclose(dlhandle_curses);
+if (dlhandle_curses) dlclose(dlhandle_curses);

-if (dlhandle != NULL)
+if (dlhandle)
   {
   /* Checked manual pages; at least in GNU Readline 6.1, the prototypes are:
    *   char * readline (const char *prompt);
@@ -1277,9 +1277,7 @@ if (dlhandle != NULL)
   *fn_addhist_ptr = (void(*)(const char*))dlsym(dlhandle, "add_history");
   }
 else
-  {
   DEBUG(D_any) debug_printf("failed to load readline: %s\n", dlerror());
-  }


return dlhandle;
}