aboutsummaryrefslogtreecommitdiffstats
path: root/g10/parse-packet.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-05-26 09:29:02 +0000
committerWerner Koch <[email protected]>2009-05-26 09:29:02 +0000
commit21ad035cc9fef070df8ff09aaebad604411442c7 (patch)
tree4d574eb10b880837f7eb785fc3f8d9e3ccd4aa28 /g10/parse-packet.c
parentMake PIN changing code work for v2 cards. (diff)
downloadgnupg-21ad035cc9fef070df8ff09aaebad604411442c7.tar.gz
gnupg-21ad035cc9fef070df8ff09aaebad604411442c7.zip
Fix a signal cleanup problem.
Fix zero length MPI reading.
Diffstat (limited to 'g10/parse-packet.c')
-rw-r--r--g10/parse-packet.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index fd01e7635..324ab5e2e 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -139,9 +139,19 @@ mpi_read (iobuf_t inp, unsigned int *ret_nread, int secure)
p[i+2] = iobuf_get(inp) & 0xff;
nread++;
}
- if ( gcry_mpi_scan( &a, GCRYMPI_FMT_PGP, buf, nread, &nread ) )
- a = NULL;
-
+
+ if (nread >= 2 && !(buf[0] << 8 | buf[1]))
+ {
+ /* Libgcrypt < 1.5.0 accidently rejects zero-length (i.e. zero)
+ MPIs. We fix this here. */
+ a = gcry_mpi_new (0);
+ }
+ else
+ {
+ if ( gcry_mpi_scan( &a, GCRYMPI_FMT_PGP, buf, nread, &nread ) )
+ a = NULL;
+ }
+
leave:
gcry_free(buf);
if ( nread > *ret_nread )