]> git.zerfleddert.de Git - rsbs2/commitdiff
solved the mistrey of 4 unknown bytes, only one left
authorMichael Gernoth <michael@gernoth.net>
Sat, 31 Jan 2009 22:44:37 +0000 (23:44 +0100)
committerMichael Gernoth <michael@gernoth.net>
Sat, 31 Jan 2009 22:44:37 +0000 (23:44 +0100)
extract.c

index 6c30bd22eace6c727bc0e6a154b28be2a6aecb1c..5d2a6fc8b6d7d1ca2076168e9d7b8060623b3888 100644 (file)
--- a/extract.c
+++ b/extract.c
@@ -15,8 +15,9 @@
 void extract_files(unsigned char *fw, int len)
 {
        unsigned char *pos;
 void extract_files(unsigned char *fw, int len)
 {
        unsigned char *pos;
-       unsigned int length;
-       unsigned char unknown[5];
+       unsigned int content_length;
+       unsigned int name_length;
+       unsigned char unknown;
        char *name;
 
        pos = fw + 0x28;
        char *name;
 
        pos = fw + 0x28;
@@ -25,26 +26,25 @@ void extract_files(unsigned char *fw, int len)
        pos = fw + *((unsigned int*)pos);
 
        while (pos < (fw + len)) {
        pos = fw + *((unsigned int*)pos);
 
        while (pos < (fw + len)) {
-               unknown[0] = *pos; pos++;
-               unknown[1] = *pos; pos++;
-               unknown[2] = *pos; pos++;
-               unknown[3] = *pos; pos++;
-               unknown[4] = *pos; pos++;
-               length = *((unsigned int*)pos);
+               unknown = *pos; pos++;
+               name_length = *((unsigned int*)pos);
+               pos += 4;
+               content_length = *((unsigned int*)pos);
                pos += 4;
                name = (char*)pos;
                pos += 4;
                name = (char*)pos;
-               pos += strlen(name) + 1;
 
 
-               if ((pos + length) > (fw + len)) {
+               if (((pos + content_length) > (fw + len)) ||
+                   ((pos + name_length) > (fw + len))) {
                        printf("EOF reached\n");
                        break;
                }
                        printf("EOF reached\n");
                        break;
                }
-               printf("%s: unknown: %02x %02x %02x %02x %02x, length: %d",
-                       name, unknown[0], unknown[1], unknown[2], unknown[3],
-                       unknown[4], length);
+               pos += name_length;
+
+               printf("%s: unknown: 0x%02x, length: %d",
+                       name, unknown, content_length);
 
 
-               if (length > 0) {
-                       write_file(name, pos, length);
+               if (content_length > 0) {
+                       write_file(name, pos, content_length);
                        if (*((unsigned int*)pos) == LZ_MAGIC) {
                                char *lzname;
 
                        if (*((unsigned int*)pos) == LZ_MAGIC) {
                                char *lzname;
 
@@ -80,7 +80,7 @@ void extract_files(unsigned char *fw, int len)
                        }
                }
 
                        }
                }
 
-               pos += length;
+               pos += content_length;
 
        }
 }
 
        }
 }
Impressum, Datenschutz