#include <string.h>
#include <strings.h>
#include "rsb-crc.h"
-#include "rsb-lz.h"
+#include "extract.h"
#define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str)))
ret = check_crc(fw, statbuf.st_size);
if ((ret != 0) && (!update_crc)) {
fprintf(stderr,"Checksum incorrect, aborting...\n");
+ exit(1);
}
if (patch_fw) {
}
if (extract) {
- search_lz_sections(fw, statbuf.st_size - 4);
+ extract_files(fw, statbuf.st_size - 4);
}
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;