diff options
-rw-r--r-- | archival/dpkg.c | 10 | ||||
-rw-r--r-- | dpkg.c | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index ffe746703..189b0a898 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -517,10 +517,19 @@ unsigned int fill_package_struct(char *control_buffer) | |||
517 | field_start += (field_length + 1); | 517 | field_start += (field_length + 1); |
518 | 518 | ||
519 | seperator_offset = strcspn(field, ":"); | 519 | seperator_offset = strcspn(field, ":"); |
520 | if (seperator_offset == 0) { | ||
521 | free(field); | ||
522 | continue; | ||
523 | } | ||
520 | field_name = xstrndup(field, seperator_offset); | 524 | field_name = xstrndup(field, seperator_offset); |
521 | field_value = field + seperator_offset + 1; | 525 | field_value = field + seperator_offset + 1; |
522 | field_value += strspn(field_value, " \n\t"); | 526 | field_value += strspn(field_value, " \n\t"); |
523 | 527 | ||
528 | /* Should be able to replace this strlen with pointer arithmatic */ | ||
529 | if (strlen(field_value) == 0) { | ||
530 | goto fill_package_struct_cleanup; // Oh no, the dreaded goto statement !! | ||
531 | } | ||
532 | |||
524 | if (strcmp(field_name, "Package") == 0) { | 533 | if (strcmp(field_name, "Package") == 0) { |
525 | new_node->name = search_name_hashtable(field_value); | 534 | new_node->name = search_name_hashtable(field_value); |
526 | } | 535 | } |
@@ -551,6 +560,7 @@ unsigned int fill_package_struct(char *control_buffer) | |||
551 | else if (strcmp(field_name, "Enhances") == 0) { | 560 | else if (strcmp(field_name, "Enhances") == 0) { |
552 | add_split_dependencies(new_node, field_value, EDGE_ENHANCES); | 561 | add_split_dependencies(new_node, field_value, EDGE_ENHANCES); |
553 | } | 562 | } |
563 | fill_package_struct_cleanup: | ||
554 | free(field_name); | 564 | free(field_name); |
555 | free(field); | 565 | free(field); |
556 | } | 566 | } |
@@ -517,10 +517,19 @@ unsigned int fill_package_struct(char *control_buffer) | |||
517 | field_start += (field_length + 1); | 517 | field_start += (field_length + 1); |
518 | 518 | ||
519 | seperator_offset = strcspn(field, ":"); | 519 | seperator_offset = strcspn(field, ":"); |
520 | if (seperator_offset == 0) { | ||
521 | free(field); | ||
522 | continue; | ||
523 | } | ||
520 | field_name = xstrndup(field, seperator_offset); | 524 | field_name = xstrndup(field, seperator_offset); |
521 | field_value = field + seperator_offset + 1; | 525 | field_value = field + seperator_offset + 1; |
522 | field_value += strspn(field_value, " \n\t"); | 526 | field_value += strspn(field_value, " \n\t"); |
523 | 527 | ||
528 | /* Should be able to replace this strlen with pointer arithmatic */ | ||
529 | if (strlen(field_value) == 0) { | ||
530 | goto fill_package_struct_cleanup; // Oh no, the dreaded goto statement !! | ||
531 | } | ||
532 | |||
524 | if (strcmp(field_name, "Package") == 0) { | 533 | if (strcmp(field_name, "Package") == 0) { |
525 | new_node->name = search_name_hashtable(field_value); | 534 | new_node->name = search_name_hashtable(field_value); |
526 | } | 535 | } |
@@ -551,6 +560,7 @@ unsigned int fill_package_struct(char *control_buffer) | |||
551 | else if (strcmp(field_name, "Enhances") == 0) { | 560 | else if (strcmp(field_name, "Enhances") == 0) { |
552 | add_split_dependencies(new_node, field_value, EDGE_ENHANCES); | 561 | add_split_dependencies(new_node, field_value, EDGE_ENHANCES); |
553 | } | 562 | } |
563 | fill_package_struct_cleanup: | ||
554 | free(field_name); | 564 | free(field_name); |
555 | free(field); | 565 | free(field); |
556 | } | 566 | } |