Process extra empty lines correctly.
authorMatt Kraai <kraai@debian.org>
Thu, 18 Oct 2001 17:03:59 +0000 (17:03 -0000)
committerMatt Kraai <kraai@debian.org>
Thu, 18 Oct 2001 17:03:59 +0000 (17:03 -0000)
archival/dpkg.c
dpkg.c

index 95c8b88cbbef4cd4d84791f8b6c63ea1a6685ecc..d566bfe5bac48b3159f51108ad846bb368b6b687 100644 (file)
@@ -769,7 +769,11 @@ void write_status_file(deb_file_t **deb_file)
 
        /* Update previously known packages */
        while ((control_buffer = fgets_str(old_status_file, "\n\n")) != NULL) {
-               tmp_string = strstr(control_buffer, "Package:") + 8;
+               if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) {
+                       continue;
+               }
+
+               tmp_string += 8;
                tmp_string += strspn(tmp_string, " \n\t");
                package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
                write_flag = FALSE;
diff --git a/dpkg.c b/dpkg.c
index 95c8b88cbbef4cd4d84791f8b6c63ea1a6685ecc..d566bfe5bac48b3159f51108ad846bb368b6b687 100644 (file)
--- a/dpkg.c
+++ b/dpkg.c
@@ -769,7 +769,11 @@ void write_status_file(deb_file_t **deb_file)
 
        /* Update previously known packages */
        while ((control_buffer = fgets_str(old_status_file, "\n\n")) != NULL) {
-               tmp_string = strstr(control_buffer, "Package:") + 8;
+               if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) {
+                       continue;
+               }
+
+               tmp_string += 8;
                tmp_string += strspn(tmp_string, " \n\t");
                package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
                write_flag = FALSE;