From 8da836e76f1349f4587d1bb74864b11dde7b8a39 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 12 Feb 2015 18:54:17 +0100 Subject: [PATCH] gpg: Fix a NULL-deref in export due to invalid packet lengths. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * g10/build-packet.c (write_fake_data): Take care of a NULL stored as opaque MPI. -- Reported-by: Hanno Böck (back ported from commit 0835d2f44ef62eab51fce6a927908f544e01cf8f) --- g10/build-packet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/g10/build-packet.c b/g10/build-packet.c index 2e6dfc026..538f2fe13 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -220,7 +220,8 @@ write_fake_data (IOBUF out, gcry_mpi_t a) 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 ); } }