trivial: Make the NULL padding detection safer

This commit is contained in:
Richard Hughes 2016-11-22 13:42:30 +00:00
parent 87764f0cc1
commit fb049f75b7

View File

@ -583,8 +583,8 @@ fu_rom_load_data (FuRom *rom,
gboolean found_data = FALSE; gboolean found_data = FALSE;
/* check it's not just NUL padding */ /* check it's not just NUL padding */
for (guint i = 0; i < hdr_sz + jump; i++) { for (guint i = jump + hdr_sz; i < buffer_sz; i++) {
if (buffer[hdr_sz + jump + i] != 0x00) { if (buffer[i] != 0x00) {
found_data = TRUE; found_data = TRUE;
break; break;
} }
@ -602,7 +602,8 @@ fu_rom_load_data (FuRom *rom,
hdr->image_len = hdr->rom_len; hdr->image_len = hdr->rom_len;
g_ptr_array_add (priv->hdrs, hdr); g_ptr_array_add (priv->hdrs, hdr);
} else { } else {
g_debug ("ignoring padding"); g_debug ("ignoring 0x%04x bytes of padding",
(guint) (buffer_sz - (jump + hdr_sz)));
} }
break; break;
} }