summaryrefslogtreecommitdiff
path: root/apps/plugins/iriver_flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/iriver_flash.c')
-rw-r--r--apps/plugins/iriver_flash.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c
index 9454ac63c8..152ac339ff 100644
--- a/apps/plugins/iriver_flash.c
+++ b/apps/plugins/iriver_flash.c
@@ -23,6 +23,7 @@
23 ****************************************************************************/ 23 ****************************************************************************/
24#include "plugin.h" 24#include "plugin.h"
25#include "lib/helper.h" 25#include "lib/helper.h"
26#include "checksum.h"
26 27
27/* 28/*
28 * Flash commands may rely on null pointer dereferences to work correctly. 29 * Flash commands may rely on null pointer dereferences to work correctly.
@@ -395,7 +396,6 @@ static bool load_firmware(const char* filename, enum firmware firmware,
395 { 396 {
396 uint32_t checksum; 397 uint32_t checksum;
397 uint8_t model[4]; 398 uint8_t model[4];
398 uint32_t sum;
399 399
400 /* subtract the header length */ 400 /* subtract the header length */
401 fd_len -= sizeof(checksum) + sizeof(model); 401 fd_len -= sizeof(checksum) + sizeof(model);
@@ -418,13 +418,8 @@ static bool load_firmware(const char* filename, enum firmware firmware,
418 goto bail; 418 goto bail;
419 } 419 }
420 420
421 /* calculate the checksum */
422 sum = MODEL_NUMBER;
423 for (off_t i = 0; i < fd_len; i++)
424 sum += buffer[i];
425
426 /* verify the checksum */ 421 /* verify the checksum */
427 if (sum != checksum) 422 if (!verify_checksum(checksum, buffer, fd_len))
428 { 423 {
429 msg = "Aborting: checksum mismatch"; 424 msg = "Aborting: checksum mismatch";
430 goto bail; 425 goto bail;