FS#10740 - rbutil: Test Cowon D2 OF file for CRC consistency before patching

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23470 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomer Shalev 2009-11-01 18:26:00 +00:00
parent 50edc5819e
commit bcadf96066
5 changed files with 55 additions and 6 deletions

View file

@ -175,6 +175,12 @@ error:
return NULL;
}
/* A CRC test in order to reject non OF file */
int test_firmware_tcc(unsigned char* buf, int length)
{
return telechips_test_crc(buf, length);
}
#ifndef LIB
int main(int argc, char *argv[])
{
@ -185,7 +191,7 @@ int main(int argc, char *argv[])
unsigned char *boot_buf = NULL;
unsigned char* image = NULL;
int ret = 0;
if(argc < 3) {
usage();
}
@ -202,6 +208,14 @@ int main(int argc, char *argv[])
goto error_exit;
}
/* Validate input file */
if (test_firmware_tcc(of_buf, of_size))
{
printf("[ERR] Unknown OF file used, aborting\n");
ret = 2;
goto error_exit;
}
boot_buf = file_read(bootfile, &boot_size);
if (!boot_buf)
{

View file

@ -35,6 +35,9 @@ unsigned char *patch_firmware_tcc(unsigned char *of_buf, int of_size,
unsigned char *file_read(char *filename, int *size);
/* Test TCC firmware file for consistency using CRC test */
int test_firmware_tcc(unsigned char* buf, int length);
#ifdef __cplusplus
};
#endif

View file

@ -81,6 +81,14 @@ void BootloaderInstallTcc::installStage2(void)
goto exit;
}
/* A CRC test in order to reject non OF file */
if (test_firmware_tcc(of_buf, of_size))
{
emit logItem(errstr, LOGERROR);
emit logItem(tr("Unknown OF file used: %1").arg(m_offile), LOGERROR);
goto exit;
}
/* Load bootloader file */
boot_buf = file_read(bootfile.toLocal8Bit().data(), &boot_size);
if (boot_buf == NULL)