gpapa key generation
Bernhard Herzog
bh@intevation.de
04 Jan 2001 16:18:21 +0100
I'm currently working on the key generation dialog and the way key
generation works with gpapa seems a bit strange to me. In keysmenu.c
lines 2166ff (the keys_generateKey_generate function) there's the
following code (only the significant parts):
/* ... */
GpapaPublicKey *publicKey;
GpapaSecretKey *secretKey;
GpapaKey *dummyKey; /*!!! */
/* ... */
dummyKey = gpapa_key_new (_("DUMMY"), gpa_callback, keeperGenerate->window); /*!!! */
publicKey = (GpapaPublicKey *) xmalloc (sizeof (GpapaPublicKey)); /*!!! */
publicKey->key = dummyKey; /*!!! */
secretKey = (GpapaSecretKey *) xmalloc (sizeof (GpapaSecretKey)); /*!!! */
secretKey->key = dummyKey; /*!!! */
/* ... */
gpapa_create_key_pair (&publicKey, &secretKey,
gtk_entry_get_text (GTK_ENTRY (entryPasswd)),
algo, keysize, userID, email, comment,
gpa_callback, keeperGenerate->window);
Why are publicKey and secretKey initialized at all? The implementation
of gpapa_create_key_pair overwrites them anyway without ever looking at
the values passed into it. That's at least a memory leak.
Later in keys_generateKey_generate, dummyKey, publicKey and secretKey
are free'd:
gpapa_key_release (dummyKey, gpa_callback, keeperGenerate->window); /*!!! */
free (publicKey); /*!!! */
free (secretKey); /*!!! */
Is it even correct to do that?
Bernhard
--
Intevation GmbH http://intevation.de/
MapIt! http://mapit.de/
Sketch http://sketch.sourceforge.net/