cscvs to tla changeset 57
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:27 +0000 (23:47 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:27 +0000 (23:47 +0000)
Author: noodles
Date: 2003/02/12 22:50:31
Handle unknown length packet stream data more gracefully.

parsekey.c

index a2ff57847e4cea077bfb8d8672a595d70cafa12a..4ec7ef3338a43d2d7a02502bbe02ab6f5d7d39cd 100644 (file)
@@ -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",