1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-17 15:44:34 +02:00

Fix usage of dlerror to conform to POSIX.

* cipher/idea-stub.c: Clear last error before dlsym.
--

This is required for NetBSD.

Reported-by: Thomas Klausner
This commit is contained in:
Werner Koch 2012-11-07 21:38:27 +01:00
parent b1abc01d4a
commit c3a5448379

View File

@ -25,9 +25,9 @@
problem with this, please see http://www.noepatents.org. problem with this, please see http://www.noepatents.org.
However for research purposes and in certain situations it might be However for research purposes and in certain situations it might be
useful to use this algorithm anyway. useful to use this algorithm anyway.
We provide this stub which will dynload a idea module and is only We provide this stub which will dynload a idea module and is only
used if the configure run did't found statically linked file. used if the configure run did't found statically linked file.
See http://www.gnupg.org/why-not-dea.html for details. See http://www.gnupg.org/why-not-dea.html for details.
*/ */
@ -55,12 +55,12 @@
#define USE_DYNAMIC_LINKING 1 #define USE_DYNAMIC_LINKING 1
static int last_error = 0; static int last_error = 0;
void* void*
dlopen (const char *pathname, int mode) dlopen (const char *pathname, int mode)
{ {
void *h = LoadLibrary (pathname); void *h = LoadLibrary (pathname);
if (!h) if (!h)
{ {
log_error ("LoadLibrary failed: %s\n", w32_strerror (errno)); log_error ("LoadLibrary failed: %s\n", w32_strerror (errno));
last_error = 1; last_error = 1;
@ -130,14 +130,16 @@ load_module (const char *name)
goto failure; goto failure;
} }
dlerror (); /* Clear old errors or initialize dlerror. */
sym = dlsym (handle, "idea_get_info"); sym = dlsym (handle, "idea_get_info");
if (dlerror ()) if (dlerror ())
sym = dlsym (handle, "_idea_get_info"); sym = dlsym (handle, "_idea_get_info");
if ((err=dlerror())) if ((err=dlerror()))
goto failure; goto failure;
return (INFO_FNC)sym; return (INFO_FNC)sym;
failure: failure:
log_info ("invalid module `%s': %s\n", name?name:"???", err?err:"???"); log_info ("invalid module `%s': %s\n", name?name:"???", err?err:"???");
if (handle) if (handle)