From 7b0a7c71483bd771d611eec408295b498e216982 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 8 Oct 2021 17:23:33 +0900 Subject: [PATCH] gpg: Support MPI(0) by sos_read and mpi_print. * g10/misc.c (mpi_print): Handle the case for MPI(0). * g10/parse-packet.c (sos_read): Likewise. -- Signed-off-by: NIIBE Yutaka --- g10/misc.c | 2 +- g10/parse-packet.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/g10/misc.c b/g10/misc.c index c329bef55..299038fd4 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1846,7 +1846,7 @@ mpi_print (estream_t fp, gcry_mpi_t a, int mode) unsigned int nbits; unsigned char *p = gcry_mpi_get_opaque (a, &nbits); if (!p) - n += es_fprintf (fp, "[invalid opaque value]"); + n += es_fprintf (fp, "[NONE]"); else { if (!es_write_hexstring (fp, p, (nbits + 7)/8, 0, &nwritten)) diff --git a/g10/parse-packet.c b/g10/parse-packet.c index bb05eabb7..caea138d3 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -229,7 +229,10 @@ sos_read (iobuf_t inp, unsigned int *ret_nread, int secure) } nbytes = (nbits + 7) / 8; - buf = secure ? gcry_xmalloc_secure (nbytes) : gcry_xmalloc (nbytes); + if (nbytes) + buf = secure ? gcry_xmalloc_secure (nbytes) : gcry_xmalloc (nbytes); + else + buf = NULL; p = buf; for (i = 0; i < nbytes; i++) {