gpg: Fix a NULL-deref in export due to invalid packet lengths.
authorWerner Koch <wk@gnupg.org>
Thu, 12 Feb 2015 17:54:17 +0000 (18:54 +0100)
committerWerner Koch <wk@gnupg.org>
Thu, 12 Feb 2015 17:54:17 +0000 (18:54 +0100)
* g10/build-packet.c (write_fake_data): Take care of a NULL stored as
opaque MPI.
--

Reported-by: Hanno Böck <hanno@hboeck.de>
(back ported from commit 0835d2f44ef62eab51fce6a927908f544e01cf8f)

g10/build-packet.c

index 2e6dfc0..538f2fe 100644 (file)
@@ -220,7 +220,8 @@ write_fake_data (IOBUF out, gcry_mpi_t a)
       void *p;
 
       p = gcry_mpi_get_opaque ( a, &n );
       void *p;
 
       p = gcry_mpi_get_opaque ( a, &n );
-      iobuf_write (out, p, (n+7)/8 );
+      if (p)
+        iobuf_write (out, p, (n+7)/8 );
     }
 }
 
     }
 }