minor fixes to g10/passphrase.c

Matt Kraai kraai@alumni.carnegiemellon.edu
Thu, 28 Sep 2000 21:20:15 -0700


--wchHw8dVAp53YPj8
Content-Type: multipart/mixed; boundary="BRE3mIcgqKzpedwo"


--BRE3mIcgqKzpedwo
Content-Type: text/plain; charset=us-ascii

Howdy,

The attached patch fixes two memory leaks, eliminates an unused
variable, and sanitizes a sanity check.

Matt

--BRE3mIcgqKzpedwo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch

Index: passphrase.c
===================================================================
RCS file: /home/koch/cvs/gnupg/g10/passphrase.c,v
retrieving revision 1.41
diff -u -r1.41 passphrase.c
--- passphrase.c	2000/09/18 14:35:29	1.41
+++ passphrase.c	2000/09/29 01:22:21
@@ -110,9 +110,10 @@
 	    char *pw2 = pw;
 	    len += 100;
 	    pw = gcry_xmalloc_secure( len );
-	    if( pw2 )
+	    if( pw2 ) {
 		memcpy(pw, pw2, i );
-	    else
+		gcry_free( pw2 );
+	    } else
 		i=0;
 	}
 	if( read( fd, pw+i, 1) != 1 || pw[i] == '\n' )
@@ -155,9 +156,7 @@
 {
     size_t nleft = buflen;
     int nread;
-    char *p;
 
-    p = buf;
     while( nleft > 0 ) {
         nread = read ( fd, buf, nleft );
         if( nread < 0 ) {
@@ -267,8 +266,10 @@
 #endif
 
     memset (fpr, 0, MAX_FINGERPRINT_LEN );
-    if( keyid && get_pubkey( pk, keyid ) )
-        pk = NULL; /* oops: no key for some reason */
+    if( !keyid || get_pubkey( pk, keyid ) ) {
+        log_debug ("oops, no key in agent_get_passphrase\n");
+        goto failure; /* oops: no key for some reason */
+    }
 
     if ( !mode && pk ) { 
         char *uid;

--BRE3mIcgqKzpedwo--

--wchHw8dVAp53YPj8
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE51Bh/fNdgYxVXvBARASY5AJ9DmrJVisgppdLAWqyQin7370ly3wCglka5
GaBLei/aHz7kSJSB122lOj4=
=I+Wu
-----END PGP SIGNATURE-----

--wchHw8dVAp53YPj8--