mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 11:59:02 +00:00
trivial: Use fu_bytes_new_offset() in more places
This commit is contained in:
parent
0e74b89282
commit
b6ad1f248e
@ -230,9 +230,13 @@ fu_efi_firmware_file_parse(FuFirmware *firmware,
|
||||
|
||||
/* verify header checksum */
|
||||
if ((flags & FWUPD_INSTALL_FLAG_IGNORE_CHECKSUM) == 0) {
|
||||
g_autoptr(GBytes) hdr_blob =
|
||||
g_bytes_new_from_bytes(fw, 0x0, FU_EFI_FIRMWARE_FILE_SIZE);
|
||||
guint8 hdr_checksum_verify = fu_efi_firmware_file_hdr_checksum8(hdr_blob);
|
||||
guint8 hdr_checksum_verify;
|
||||
g_autoptr(GBytes) hdr_blob = NULL;
|
||||
|
||||
hdr_blob = fu_bytes_new_offset(fw, 0x0, FU_EFI_FIRMWARE_FILE_SIZE, error);
|
||||
if (hdr_blob == NULL)
|
||||
return FALSE;
|
||||
hdr_checksum_verify = fu_efi_firmware_file_hdr_checksum8(hdr_blob);
|
||||
if (hdr_checksum_verify != hdr_checksum) {
|
||||
g_set_error(error,
|
||||
FWUPD_ERROR,
|
||||
|
@ -553,8 +553,9 @@ fu_synaptics_cape_device_prepare_firmware(FuDevice *device,
|
||||
if (self->active_partition == 1)
|
||||
offset = bufsz / 2;
|
||||
|
||||
new_fw = g_bytes_new_from_bytes(fw, offset, bufsz / 2);
|
||||
|
||||
new_fw = fu_bytes_new_offset(fw, offset, bufsz / 2, error);
|
||||
if (new_fw == NULL)
|
||||
return NULL;
|
||||
if (!fu_firmware_parse(firmware, new_fw, flags, error))
|
||||
return NULL;
|
||||
|
||||
|
@ -184,11 +184,15 @@ fu_synaptics_cape_firmware_parse(FuFirmware *firmware,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fw_header = g_bytes_new_from_bytes(fw, 0x0, headsz);
|
||||
fw_header = fu_bytes_new_offset(fw, 0x0, headsz, error);
|
||||
if (fw_header == NULL)
|
||||
return FALSE;
|
||||
if (!fu_synaptics_cape_firmware_parse_header(self, firmware, fw_header, error))
|
||||
return FALSE;
|
||||
|
||||
fw_body = g_bytes_new_from_bytes(fw, headsz, bufsz - headsz);
|
||||
fw_body = fu_bytes_new_offset(fw, headsz, bufsz - headsz, error);
|
||||
if (fw_body == NULL)
|
||||
return FALSE;
|
||||
fu_firmware_set_id(firmware, FU_FIRMWARE_ID_PAYLOAD);
|
||||
fu_firmware_set_bytes(firmware, fw_body);
|
||||
return TRUE;
|
||||
|
@ -317,7 +317,9 @@ fu_synaptics_rmi_v5_device_write_firmware(FuDevice *device,
|
||||
return FALSE;
|
||||
|
||||
/* verify signature if set */
|
||||
firmware_bin = g_bytes_new_from_bytes(bytes_bin, 0, firmware_length);
|
||||
firmware_bin = fu_bytes_new_offset(bytes_bin, 0, firmware_length, error);
|
||||
if (firmware_bin == NULL)
|
||||
return FALSE;
|
||||
signature_bin = fu_firmware_get_image_by_id_bytes(firmware, "sig", NULL);
|
||||
if (signature_bin != NULL) {
|
||||
if (!fu_synaptics_rmi_v5_device_secure_check(device,
|
||||
|
Loading…
Reference in New Issue
Block a user