mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 16:11:22 +00:00
Keep hitting the hardware until it gives us enough ROM
This commit is contained in:
parent
5e330b0f0c
commit
885128a7c8
27
src/fu-rom.c
27
src/fu-rom.c
@ -245,6 +245,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, GCancellable *cancellable, GError **e
|
||||
gchar *str;
|
||||
guint hdr_sz = 0;
|
||||
guint i;
|
||||
guint number_reads = 0;
|
||||
gssize sz;
|
||||
_cleanup_free_ gchar *fn = NULL;
|
||||
_cleanup_error_free_ GError *error_local = NULL;
|
||||
@ -287,6 +288,32 @@ fu_rom_load_file (FuRom *rom, GFile *file, GCancellable *cancellable, GError **e
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* ensure we got enough data to fill the buffer */
|
||||
while (sz < 0x4000) {
|
||||
gssize sz_chunk;
|
||||
sz_chunk = g_input_stream_read (priv->stream,
|
||||
buffer + sz,
|
||||
block_sz - sz,
|
||||
cancellable,
|
||||
error);
|
||||
if (sz_chunk == 0)
|
||||
break;
|
||||
g_debug ("ROM returned 0x%04x bytes, adding 0x%04x...",
|
||||
(guint) sz, (guint) sz_chunk);
|
||||
if (sz_chunk < 0)
|
||||
return FALSE;
|
||||
sz += sz_chunk;
|
||||
|
||||
/* check the firmware isn't serving us small chunks */
|
||||
if (number_reads++ > 16) {
|
||||
g_set_error_literal (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_INVALID_FILE,
|
||||
"firmware not fulfilling requests");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* detect signed header and skip to option ROM */
|
||||
if (memcmp (buffer, "NVGI", 4) == 0)
|
||||
hdr_sz = GUINT16_FROM_BE (buffer[0x15]);
|
||||
|
Loading…
Reference in New Issue
Block a user