From fb049f75b7b64a4025f25f69d65bf095ca82ca78 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 22 Nov 2016 13:42:30 +0000 Subject: [PATCH] trivial: Make the NULL padding detection safer --- src/fu-rom.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fu-rom.c b/src/fu-rom.c index e491d8ace..4520103c3 100644 --- a/src/fu-rom.c +++ b/src/fu-rom.c @@ -583,8 +583,8 @@ fu_rom_load_data (FuRom *rom, gboolean found_data = FALSE; /* check it's not just NUL padding */ - for (guint i = 0; i < hdr_sz + jump; i++) { - if (buffer[hdr_sz + jump + i] != 0x00) { + for (guint i = jump + hdr_sz; i < buffer_sz; i++) { + if (buffer[i] != 0x00) { found_data = TRUE; break; } @@ -602,7 +602,8 @@ fu_rom_load_data (FuRom *rom, hdr->image_len = hdr->rom_len; g_ptr_array_add (priv->hdrs, hdr); } else { - g_debug ("ignoring padding"); + g_debug ("ignoring 0x%04x bytes of padding", + (guint) (buffer_sz - (jump + hdr_sz))); } break; }