Skip to content

Commit

Permalink
another verification stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Naim2000 committed Nov 5, 2023
1 parent 19eaa8d commit 5c5f598
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Binary file added cdbackup.zip
Binary file not shown.
20 changes: 18 additions & 2 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,28 @@ int restore() {
}
printf("OK!\n");

if(memcmp(buffer, "VFF ", 4) != 0) {
printf("\x1b[41;30m this isn't a VFF file... [0x%08x != 0x%08x (\"VFF \")] \x1b[40;37m", *(unsigned int*)buffer, 0x56464620);
printf("Verifying... ");
if (!filesize) {
printf("this file is 0 bytes..?\n");
free(buffer);
return -EINVAL;
}

else if (memcmp(buffer, "VFF ", 4) != 0) {
printf("this isn't a VFF file!\n[0x%08x != 0x%08x \"VFF \"]\n", *(unsigned int*)buffer, 0x56464620);
free(buffer);
return -EINVAL;
}

else if (filesize < (20 * 1024 * 1024)) {
printf("this file is smaller than usual... (<20MiB)\n");
free(buffer);
return -EINVAL;
}

else
printf("OK!\n");

printf("Writing to %s on NAND...\n", cdb_filepath);
ret = FS_Write(cdb_filepath, buffer, filesize, &progressbar);
if (ret < 0) {
Expand Down

0 comments on commit 5c5f598

Please sign in to comment.