X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=parsekey.c;h=687fd9bd8612c6f9a3cd2c41af96e9269368a620;hb=a047e3e158d560af079bec920460711d8222317c;hp=5c6b3207801d48f583e05de44229d0377e2544d2;hpb=e3ac2630467e42937478a8e03dec83693912f9c4;p=onak.git diff --git a/parsekey.c b/parsekey.c index 5c6b320..687fd9b 100644 --- a/parsekey.c +++ b/parsekey.c @@ -4,11 +4,8 @@ * Jonathan McDowell * * Copyright 2002 Project Purple - * - * $Id: parsekey.c,v 1.18 2004/01/04 18:47:35 noodles Exp $ */ -#include #include #include #include @@ -54,7 +51,7 @@ int parse_keys(struct openpgp_packet_list *packets, * key (it should be a revocation), to the current UID * or the current subkey. */ - assert(curkey != NULL); + log_assert(curkey != NULL); if (curkey->subkeys != NULL) { ADD_PACKET_TO_LIST_END(curkey->last_subkey, sig, @@ -90,8 +87,8 @@ int parse_keys(struct openpgp_packet_list *packets, /* * It's a UID packet (or a photo id, which is similar). */ - assert(curkey != NULL); - assert(curkey->subkeys == NULL); + log_assert(curkey != NULL); + log_assert(curkey->subkeys == NULL); ADD_PACKET_TO_LIST_END(curkey, uid, packet_dup(packets->packet)); @@ -100,7 +97,7 @@ int parse_keys(struct openpgp_packet_list *packets, /* * It's a subkey packet. */ - assert(curkey != NULL); + log_assert(curkey != NULL); ADD_PACKET_TO_LIST_END(curkey, subkey, packet_dup(packets->packet)); @@ -166,7 +163,7 @@ int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count, int keys = 0; bool inpacket = false; - assert(packets != NULL); + log_assert(packets != NULL); curpacket = *packets; if (curpacket != NULL) { while (curpacket->next != NULL) { @@ -225,13 +222,13 @@ int read_openpgp_stream(int (*getchar_func)(void *ctx, size_t count, curpacket->packet->length = curchar; curpacket->packet->length <<= 8; rc = getchar_func(ctx, 1, &curchar); - curpacket->packet->length = curchar; + curpacket->packet->length += curchar; curpacket->packet->length <<= 8; rc = getchar_func(ctx, 1, &curchar); - curpacket->packet->length = curchar; + curpacket->packet->length += curchar; curpacket->packet->length <<= 8; rc = getchar_func(ctx, 1, &curchar); - curpacket->packet->length = curchar; + curpacket->packet->length += curchar; } } else { curpacket->packet->tag = (curchar & 0x3C) >> 2; @@ -334,6 +331,28 @@ int write_openpgp_stream(int (*putchar_func)(void *ctx, size_t count, curchar = (packets->packet->length - 192) & 0xFF; putchar_func(ctx, 1, &curchar); + } else if (packets->packet->length > 8382 && + packets->packet->length < 0xFFFFFFFF) { + logthing(LOGTHING_DEBUG, + "Writing 5 byte length"); + curchar = 255; + putchar_func(ctx, 1, &curchar); + + curchar = (packets->packet->length >> 24); + curchar &= 0xFF; + putchar_func(ctx, 1, &curchar); + + curchar = (packets->packet->length >> 16); + curchar &= 0xFF; + putchar_func(ctx, 1, &curchar); + + curchar = (packets->packet->length >> 8); + curchar &= 0xFF; + putchar_func(ctx, 1, &curchar); + + curchar = packets->packet->length; + curchar &= 0xFF; + putchar_func(ctx, 1, &curchar); } else { logthing(LOGTHING_ERROR, "Unsupported new format length.");