]> git.zerfleddert.de Git - rsbs2/commitdiff
don't ever update the checksum of a corrupt image
authorMichael Gernoth <michael@gernoth.net>
Sun, 1 Feb 2009 12:21:32 +0000 (13:21 +0100)
committerMichael Gernoth <michael@gernoth.net>
Sun, 1 Feb 2009 12:21:32 +0000 (13:21 +0100)
extract.c
firmware.c

index 86491d1cfcf47541f5dc15a255832e6c8d030f77..784821bf9ff856d8d20e8195cf4370f174654a01 100644 (file)
--- a/extract.c
+++ b/extract.c
@@ -22,7 +22,9 @@ struct file_entry* get_next_file(unsigned char *fw, int len)
        if (fw != NULL && len != 0) {
                pos = fw + 0x28;
 
+#if 0
                printf("Start of filesystem: 0x%08x\n", *((unsigned int*)pos));
+#endif
                pos = fw + *((unsigned int*)pos);
                end = fw + len;
        }
@@ -38,7 +40,9 @@ struct file_entry* get_next_file(unsigned char *fw, int len)
 
        if ((fent.length > (end - pos)) ||
            (name_length > (end - pos))) {
+#if 0
                printf("EOF reached\n");
+#endif
                return NULL;
        }
 
index cd7927b8f9854d86c20696adcfaabd8285f18dbf..e73d7cc817210913817de5c6cca8d1f1ee031274 100644 (file)
@@ -466,6 +466,20 @@ int main(int argc, char **argv)
        }
 
        if (update_crc || patch_fw || patch_bd) {
+               struct file_entry *fent;
+               char *last_name = NULL;
+
+               fent = get_next_file(fw, statbuf.st_size - 4);
+               while (fent != NULL) {
+                       last_name = fent->name;
+                       fent = get_next_file(NULL, 0);
+               }
+
+               if (strcmp(last_name, "pdata")) {
+                       fprintf(stderr, "corrupt firmware image found (pdata is not last entry, aborting!\n");
+                       exit(1);
+               }
+
                ret = rsb_crc2(fw, statbuf.st_size, 0x55335053, &crc);
                if (ret == 4) {
                        *((unsigned int*)(fw + statbuf.st_size - 4)) = crc;
Impressum, Datenschutz