Mailing List Archive

libgpg-error crash on MinGW
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);

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: libgpg-error crash on MinGW [ In reply to ]
At Wed, 21 Jun 2006 21:13:07 +0200,
Simon Josefsson <jas@extundo.com> wrote:
>
> I get a crash in libgpg-error:

[...]

> The following patch fixes this.

Thanks, I put it in.

2006-07-04 Marcus Brinkmann <marcus@g10code.de>

* src/init.c (get_locale_dir): Return NULL instead of garbage.
* src/gpg-error.c (get_locale_dir): Likewise.
Submitted by Simon Josefsson <jas@extundo.com>.

Marcus


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: libgpg-error crash on MinGW [ In reply to ]
Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de> writes:

> At Wed, 21 Jun 2006 21:13:07 +0200,
> Simon Josefsson <jas@extundo.com> wrote:
>>
>> I get a crash in libgpg-error:
>
> [...]
>
>> The following patch fixes this.
>
> Thanks, I put it in.

Seems to work fine here, thanks!

> 2006-07-04 Marcus Brinkmann <marcus@g10code.de>
>
> * src/init.c (get_locale_dir): Return NULL instead of garbage.
> * src/gpg-error.c (get_locale_dir): Likewise.
> Submitted by Simon Josefsson <jas@extundo.com>.
>
> Marcus

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel