From: Jonathan McDowell Date: Mon, 31 May 2004 23:47:27 +0000 (+0000) Subject: cscvs to tla changeset 57 X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/62c94dacbe471278972813b59776a5fadbd8a543?ds=inline cscvs to tla changeset 57 Author: noodles Date: 2003/02/12 22:50:31 Handle unknown length packet stream data more gracefully. --- 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",