summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-04-05 19:19:27 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-04-05 19:19:27 +0000
commit9def6b23450ea17d12fec9b9ea3c9ecfa62a8fb1 (patch)
tree74433c73bb3e27c94f1ede70192e57cab9858779
parentafc78cc329a901023b24e69ce57d0ab06e507469 (diff)
downloadrockbox-9def6b23450ea17d12fec9b9ea3c9ecfa62a8fb1.tar.gz
rockbox-9def6b23450ea17d12fec9b9ea3c9ecfa62a8fb1.zip
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
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallsansa.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
index a78f336144..4679c2e9a8 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
@@ -122,9 +122,26 @@ void BootloaderInstallSansa::installStage2(void)
122 return; 122 return;
123 } 123 }
124 124
125 // check model -- if sansapatcher reports a c200 don't install an e200
126 // bootloader and vice versa.
127 // The model is available in the mi4 file at offset 0x1fc and matches
128 // the targetname set by sansapatcher.
129 emit logItem(tr("Checking downloaded bootloader"), LOGINFO);
125 m_tempfile.open(); 130 m_tempfile.open();
126 QString blfile = m_tempfile.fileName(); 131 QString blfile = m_tempfile.fileName();
132 char magic[4];
133 m_tempfile.seek(0x1fc);
134 m_tempfile.read(magic, 4);
127 m_tempfile.close(); 135 m_tempfile.close();
136 if(memcmp(sansa.targetname, magic, 4) != 0) {
137 emit logItem(tr("Bootloader mismatch! Aborting."), LOGERROR);
138 qDebug("[BL-Sansa] Targetname: %s, mi4 magic: %c%c%c%c",
139 sansa.targetname, magic[0], magic[1], magic[2], magic[3]);
140 emit done(true);
141 sansa_close(&sansa);
142 return;
143 }
144
128 if(sansa_add_bootloader(&sansa, blfile.toLatin1().data(), 145 if(sansa_add_bootloader(&sansa, blfile.toLatin1().data(),
129 FILETYPE_MI4) == 0) { 146 FILETYPE_MI4) == 0) {
130 emit logItem(tr("Successfully installed bootloader"), LOGOK); 147 emit logItem(tr("Successfully installed bootloader"), LOGOK);