GnuPG 1.2.0 crash w/ self-test genkey1024 under Solaris
Werner Koch
wk at gnupg.org
Thu Sep 26 15:19:02 CEST 2002
On Thu, 26 Sep 2002 09:50:24 +0200, Stefan Dalibor said:
> Hi,
> GnuPG 1.2.0 fails to pass its self-test genkey1024 under Solaris 8 if EGD
> is not running (crash due to calling strlen(NULL) in utils/fileutil.c,
> line 105).
The code is okay. make_filename should never return NULL and the
first part should be NULL. I added a comment to the function.
The true reason seems to be that we have opt_g10_homedir and
opt.homedir (to keep the modules a bit separate). It seems that the
random code gets initialized at a point were opt_g10_homedir is not
initialized. I have changed this in the CVS; patch attached.
> hunk 2 is indeed necessary (almost all non-glibc C libraries I know won't
> tolerate strlen(NULL)), I'm not so sure about hunk 1 (but of course, gpg
It MUST even not tolerate a NULL. The only place where tolerating a
NULL is for a %s printf argument were it is quite handy (but not portable).
Shalom-Salam,
Werner
-------------- next part --------------
Index: g10.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/g10.c,v
retrieving revision 1.159.2.3
diff -u -r1.159.2.3 g10.c
--- g10.c 15 Sep 2002 11:16:04 -0000 1.159.2.3
+++ g10.c 26 Sep 2002 12:15:07 -0000
@@ -778,6 +778,15 @@
}
+/* We need the home directory also in some other directories, so make
+ sure that both variables are always in sync. */
+static void
+set_homedir (char *dir)
+{
+ g10_opt_homedir = opt.homedir = dir;
+}
+
+
static void
set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd )
{
@@ -1092,12 +1101,13 @@
opt.keyserver_options.include_subkeys=1;
opt.keyserver_options.include_revoked=1;
#if defined (__MINGW32__) || defined (__CYGWIN32__)
- opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" );
+ set_homedir ( read_w32_registry_string( NULL,
+ "Software\\GNU\\GnuPG", "HomeDir" ));
#else
- opt.homedir = getenv("GNUPGHOME");
+ set_homedir ( getenv("GNUPGHOME") );
#endif
if( !opt.homedir || !*opt.homedir ) {
- opt.homedir = GNUPG_HOMEDIR;
+ set_homedir ( GNUPG_HOMEDIR );
}
/* check whether we have a config file on the commandline */
@@ -1118,7 +1128,7 @@
else if( pargs.r_opt == oNoOptions )
default_config = 0; /* --no-options */
else if( pargs.r_opt == oHomedir )
- opt.homedir = pargs.r.ret_str;
+ set_homedir ( pargs.r.ret_str );
else if( pargs.r_opt == oNoPermissionWarn )
opt.no_perm_warn=1;
#ifdef USE_SHM_COPROCESSING
@@ -1143,7 +1153,7 @@
for (d=buf,s=opt.homedir; *s; s++)
*d++ = *s == '\\'? '/': *s;
*d = 0;
- opt.homedir = buf;
+ set_homedir (buf);
}
#endif
#ifdef USE_SHM_COPROCESSING
@@ -1714,7 +1724,6 @@
secmem_set_flags( secmem_get_flags() & ~2 ); /* resume warnings */
set_debug();
- g10_opt_homedir = opt.homedir;
/* Do these after the switch(), so they can override settings. */
if(opt.pgp2 && (opt.pgp6 || opt.pgp7))
More information about the Gnupg-devel
mailing list