summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f0a63a7)
If read_openpgp_stream got an invalid packet that had a semi valid
header it could potentially return an empty package, which would
confuse splitkeys. Cleanup the final package returned if it turns
out we didn't have valid data for it.
Fixes Debian bug #716350
int maxnum)
{
unsigned char curchar = 0;
int maxnum)
{
unsigned char curchar = 0;
- struct openpgp_packet_list *curpacket = NULL;
+ struct openpgp_packet_list *curpacket = NULL, **packetend = NULL;
onak_status_t rc = ONAK_E_OK;
int keys = 0;
bool inpacket = false;
onak_status_t rc = ONAK_E_OK;
int keys = 0;
bool inpacket = false;
inpacket = true;
if (curpacket != NULL) {
curpacket->next = malloc(sizeof (*curpacket));
inpacket = true;
if (curpacket != NULL) {
curpacket->next = malloc(sizeof (*curpacket));
+ packetend = &curpacket->next;
curpacket = curpacket->next;
} else {
*packets = curpacket =
malloc(sizeof (*curpacket));
curpacket = curpacket->next;
} else {
*packets = curpacket =
malloc(sizeof (*curpacket));
}
memset(curpacket, 0, sizeof(*curpacket));
curpacket->packet =
}
memset(curpacket, 0, sizeof(*curpacket));
curpacket->packet =
curpacket->packet->length += 192;
} else if (curpacket->packet->length > 223 &&
curpacket->packet->length < 255) {
curpacket->packet->length += 192;
} else if (curpacket->packet->length > 223 &&
curpacket->packet->length < 255) {
- return ONAK_E_UNSUPPORTED_FEATURE;
+ free(curpacket->packet);
+ curpacket->packet = NULL;
+ rc = ONAK_E_UNSUPPORTED_FEATURE;
} else if (curpacket->packet->length == 255) {
/*
* 5 byte length; ie 255 followed by 3
} else if (curpacket->packet->length == 255) {
/*
* 5 byte length; ie 255 followed by 3
break;
case 3:
rc = ONAK_E_UNSUPPORTED_FEATURE;
break;
case 3:
rc = ONAK_E_UNSUPPORTED_FEATURE;
- curpacket->packet->length = 0;
- curpacket->packet->data = NULL;
+ free(curpacket->packet);
+ curpacket->packet = NULL;
+ /* Trim the last packet if it doesn't actually exist */
+ if (packetend != NULL && (*packetend)->packet == NULL) {
+ free(*packetend);
+ *packetend = NULL;
+ }
+
- if (tmp->next != NULL) {
+ if (tmp != NULL && tmp->next != NULL) {