From 62c94dacbe471278972813b59776a5fadbd8a543 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Mon, 31 May 2004 23:47:27 +0000 Subject: [PATCH] cscvs to tla changeset 57 Author: noodles Date: 2003/02/12 22:50:31 Handle unknown length packet stream data more gracefully. --- parsekey.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/parsekey.c b/parsekey.c index a2ff578..4ec7ef3 100644 --- a/parsekey.c +++ b/parsekey.c @@ -260,14 +260,21 @@ int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count, break; case 3: fprintf(stderr, "Unsupported length type 3.\n"); + curpacket->packet->length = 0; + curpacket->packet->data = NULL; + rc = -1; break; } } - curpacket->packet->data = - malloc(curpacket->packet->length * + + if (rc == 0) { + curpacket->packet->data = + malloc(curpacket->packet->length * sizeof(unsigned char)); - rc = getchar_func(ctx, curpacket->packet->length, + rc = getchar_func(ctx, + curpacket->packet->length, curpacket->packet->data); + } inpacket = false; } else { fprintf(stderr, "Unexpected character: 0x%X\n", -- 2.30.2