comparison sidlib.c @ 166:e6c8a235ce2f

Fix the load address handling in case of new SLDB format.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 16 Feb 2018 22:24:43 +0200
parents 179ffe97599c
children da2fbfe18c60
comparison
equal deleted inserted replaced
165:eb343ac259f4 166:e6c8a235ce2f
46 return FALSE; 46 return FALSE;
47 } 47 }
48 48
49 49
50 static BOOL si_read_hash_data(th_ioctx *ctx, PSIDHeader *psid, 50 static BOOL si_read_hash_data(th_ioctx *ctx, PSIDHeader *psid,
51 th_md5state_t *state, BOOL first) 51 th_md5state_t *state, const BOOL newSLDB)
52 { 52 {
53 uint8_t *data = NULL; 53 uint8_t *data = NULL;
54 BOOL ret = FALSE; 54 BOOL ret = FALSE, first = TRUE;
55 size_t read; 55 size_t read;
56 56
57 if ((data = (uint8_t *) th_malloc(PSID_BUFFER_SIZE)) == NULL) 57 if ((data = (uint8_t *) th_malloc(PSID_BUFFER_SIZE)) == NULL)
58 { 58 {
59 th_io_error(ctx, THERR_MALLOC, 59 th_io_error(ctx, THERR_MALLOC,
79 } 79 }
80 80
81 // Grab the load address 81 // Grab the load address
82 psid->loadAddress = TH_LE16_TO_NATIVE(*(uint16_t *) data); 82 psid->loadAddress = TH_LE16_TO_NATIVE(*(uint16_t *) data);
83 83
84 // .. do not include the load address to the hash 84 // .. do not include the load address to the hash if OLD SLDB format
85 th_md5_append(state, &data[2], read - 2); 85 if (newSLDB)
86 th_md5_append(state, data, read);
87 else
88 th_md5_append(state, &data[2], read - 2);
89
86 first = FALSE; 90 first = FALSE;
87 } 91 }
88 else 92 else
89 if (read > 0) 93 if (read > 0)
90 { 94 {