libgpg-error crash on MinGW

Simon Josefsson jas at extundo.com
Wed Jun 21 21:13:07 CEST 2006


I get a crash in libgpg-error:

(gdb) bt
#0  0x77c478ac in strlen () from /cygdrive/c/WINDOWS/system32/msvcrt.dll
#1  0x00491420 in _gpg_err_bindtextdomain (
    domainname=0x49593a "libgpg-error", 
    dirname=0xffffffff <Address 0xffffffff out of bounds>)
    at ../../libgpg-error-1.3/src/w32-gettext.c:1581
#2  0x004926ef in gpg_err_init () at ../../libgpg-error-1.3/src/init.c:58

The dirname parameter is off, and get_locale_dir is at fault:

static char *
get_locale_dir (void)
{
  char *instdir;
  char *p;
  char *dname;

  instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", REGKEY,
				      "Install Directory");
  if (!instdir)
    return;

This will return garbage if the desired registry key is not present.

For some reason this only happens on Windows XP but not Windows 2000.
Maybe the stack happened to be different...

The following patch fixes this.

Thanks,
Simon

Index: init.c
===================================================================
--- init.c	(revision 173)
+++ init.c	(working copy)
@@ -196,7 +196,7 @@
   instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", REGKEY,
 				      "Install Directory");
   if (!instdir)
-    return;
+    return NULL;
   
   /* Build the key: "<instdir>/share/locale".  */
 #define SLDIR "\\share\\locale"
@@ -204,7 +204,7 @@
   if (!dname)
     {
       free (instdir);
-      return;
+      return NULL;
     }
   p = dname;
   strcpy (p, instdir);



More information about the Gcrypt-devel mailing list