+ if (pos != end) {
+ fprintf(stderr, "EOF marker not at end-of-file %p <-> %p, aborting!\n", pos, end);
+ exit(1);
+ }
+
+ return NULL;
+ }
+
+
+ name_length = *((unsigned int*)pos);
+ pos += 4;
+
+ fent.length = *((unsigned int*)pos);
+ pos += 4;
+
+ if ((fent.length > (end - pos)) ||
+ (name_length > (end - pos))) {
+ printf("EOF reached without hitting EOF marker, aborting "
+ "(unknown: 0x%02x, namelen: 0x%08x, contentlen: 0x%08x!\n",
+ fent.unknown, name_length, fent.length);
+ exit(1);
+ }
+
+ fent.name = (char*)pos;
+ pos += name_length;
+
+ fent.start = pos;
+ pos += fent.length;
+
+ return &fent;
+}
+
+void extract_files(unsigned char *fw, int len)
+{
+ struct file_entry *fent;
+
+ fent = get_next_file(fw, len);
+
+ while (fent) {