diff options
| author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-24 21:15:29 +0000 |
|---|---|---|
| committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-24 21:15:29 +0000 |
| commit | ced10d4db18947c724d25dfc923a22c9aff3f629 (patch) | |
| tree | bc93ad2e3bdf67240947b01c6f96026c89750f03 /utils/zenutils/source/shared/updater.cpp | |
| parent | 074e48c08c439ef40416fb9b264a1f113c69a3b3 (diff) | |
| download | rockbox-ced10d4db18947c724d25dfc923a22c9aff3f629.zip rockbox-ced10d4db18947c724d25dfc923a22c9aff3f629.tar.gz rockbox-ced10d4db18947c724d25dfc923a22c9aff3f629.tar.bz2 rockbox-ced10d4db18947c724d25dfc923a22c9aff3f629.tar.xz | |
ZenUtils:
* Apply FS#9311 by Jelle Geerts: fix compiling on MingW
* Make zen::find_firmware_offset() detect the offset better
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18340 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/source/shared/updater.cpp')
| -rw-r--r-- | utils/zenutils/source/shared/updater.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/utils/zenutils/source/shared/updater.cpp b/utils/zenutils/source/shared/updater.cpp index 3944863..7efac3d 100644 --- a/utils/zenutils/source/shared/updater.cpp +++ b/utils/zenutils/source/shared/updater.cpp @@ -50,19 +50,18 @@ const char* zen::find_firmware_key(const byte* buffer, size_t len) dword zen::find_firmware_offset(byte* buffer, size_t len) { - for (dword i = 0; i < static_cast<dword>(len); i += 0x10) + for (dword i = 0; i < static_cast<dword>(len); i += 4) { dword size = *(dword*)&buffer[i]; - if (size < (i + len) && size > (len >> 1)) + if (buffer[i + sizeof(dword)] != 0 + && buffer[i + sizeof(dword) + 1] != 0 + && buffer[i + sizeof(dword) + 2] != 0 + && buffer[i + sizeof(dword) + 3] != 0) { - if (buffer[i + sizeof(dword)] != 0 - && buffer[i + sizeof(dword) + 1] != 0 - && buffer[i + sizeof(dword) + 2] != 0 - && buffer[i + sizeof(dword) + 3] != 0) - { - return i; - } + return i; } + if(i > 0xFF) /* Arbitrary guess */ + return 0; } return 0; } @@ -105,7 +104,6 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len) unsigned int tmp = 0; int key_length = strlen(key); - strcpy(key_cpy, key); for(i=0; i < strlen(key); i++) key_cpy[i] = key[i] - 1; |