diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-07-14 10:25:54 +0400 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-07-14 10:25:54 +0400 |
commit | 58a5bd187dd69ed9ba761e8ea755fd9ff4e97ce6 (patch) | |
tree | 33146c19c5c9b52d3cd9a5657d80eab1e81fc3da /archival/dpkg.c | |
parent | 06ef16563b6914735d5018a1d92fbe992f84d7fd (diff) |
Tolerate fields with no data, e.g. "Depends: "
Diffstat (limited to 'archival/dpkg.c')
-rw-r--r-- | archival/dpkg.c | 10 |
1 files changed, 10 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) field_start += (field_length + 1); seperator_offset = strcspn(field, ":"); + if (seperator_offset == 0) { + free(field); + continue; + } field_name = xstrndup(field, seperator_offset); field_value = field + seperator_offset + 1; field_value += strspn(field_value, " \n\t"); + /* Should be able to replace this strlen with pointer arithmatic */ + if (strlen(field_value) == 0) { + goto fill_package_struct_cleanup; // Oh no, the dreaded goto statement !! + } + if (strcmp(field_name, "Package") == 0) { new_node->name = search_name_hashtable(field_value); } @@ -551,6 +560,7 @@ unsigned int fill_package_struct(char *control_buffer) else if (strcmp(field_name, "Enhances") == 0) { add_split_dependencies(new_node, field_value, EDGE_ENHANCES); } +fill_package_struct_cleanup: free(field_name); free(field); } |