mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
Fix a potentially dangerous bug with bootloader installation for Sansas:
check the downloaded bootloader file against the target reported by sansapatcher as otherwise one could install an e200 bootloader to a c200 (and vice versa). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20630 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
afc78cc329
commit
9def6b2345
1 changed files with 17 additions and 0 deletions
|
|
@ -122,9 +122,26 @@ void BootloaderInstallSansa::installStage2(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check model -- if sansapatcher reports a c200 don't install an e200
|
||||||
|
// bootloader and vice versa.
|
||||||
|
// The model is available in the mi4 file at offset 0x1fc and matches
|
||||||
|
// the targetname set by sansapatcher.
|
||||||
|
emit logItem(tr("Checking downloaded bootloader"), LOGINFO);
|
||||||
m_tempfile.open();
|
m_tempfile.open();
|
||||||
QString blfile = m_tempfile.fileName();
|
QString blfile = m_tempfile.fileName();
|
||||||
|
char magic[4];
|
||||||
|
m_tempfile.seek(0x1fc);
|
||||||
|
m_tempfile.read(magic, 4);
|
||||||
m_tempfile.close();
|
m_tempfile.close();
|
||||||
|
if(memcmp(sansa.targetname, magic, 4) != 0) {
|
||||||
|
emit logItem(tr("Bootloader mismatch! Aborting."), LOGERROR);
|
||||||
|
qDebug("[BL-Sansa] Targetname: %s, mi4 magic: %c%c%c%c",
|
||||||
|
sansa.targetname, magic[0], magic[1], magic[2], magic[3]);
|
||||||
|
emit done(true);
|
||||||
|
sansa_close(&sansa);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(sansa_add_bootloader(&sansa, blfile.toLatin1().data(),
|
if(sansa_add_bootloader(&sansa, blfile.toLatin1().data(),
|
||||||
FILETYPE_MI4) == 0) {
|
FILETYPE_MI4) == 0) {
|
||||||
emit logItem(tr("Successfully installed bootloader"), LOGOK);
|
emit logItem(tr("Successfully installed bootloader"), LOGOK);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue