mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-12 20:25:48 +00:00
trivial: Allow specifying zero-sized data sections
This can be done using '<data/>' to specify a zero-sized image.
This commit is contained in:
parent
0924c93422
commit
aff64d3e75
@ -336,6 +336,7 @@ fu_firmware_image_build (FuFirmwareImage *self, XbNode *n, GError **error)
|
|||||||
FuFirmwareImageClass *klass = FU_FIRMWARE_IMAGE_GET_CLASS (self);
|
FuFirmwareImageClass *klass = FU_FIRMWARE_IMAGE_GET_CLASS (self);
|
||||||
guint64 tmpval;
|
guint64 tmpval;
|
||||||
const gchar *tmp;
|
const gchar *tmp;
|
||||||
|
g_autoptr(XbNode) data = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (FU_IS_FIRMWARE_IMAGE (self), FALSE);
|
g_return_val_if_fail (FU_IS_FIRMWARE_IMAGE (self), FALSE);
|
||||||
g_return_val_if_fail (XB_IS_NODE (n), FALSE);
|
g_return_val_if_fail (XB_IS_NODE (n), FALSE);
|
||||||
@ -365,14 +366,18 @@ fu_firmware_image_build (FuFirmwareImage *self, XbNode *n, GError **error)
|
|||||||
fu_firmware_image_set_bytes (self, blob);
|
fu_firmware_image_set_bytes (self, blob);
|
||||||
fu_firmware_image_set_filename (self, tmp);
|
fu_firmware_image_set_filename (self, tmp);
|
||||||
}
|
}
|
||||||
tmp = xb_node_query_text (n, "data", NULL);
|
data = xb_node_query_first (n, "data", NULL);
|
||||||
if (tmp != NULL) {
|
if (data != NULL && xb_node_get_text (data) != NULL) {
|
||||||
gsize bufsz = 0;
|
gsize bufsz = 0;
|
||||||
g_autofree guchar *buf = NULL;
|
g_autofree guchar *buf = NULL;
|
||||||
g_autoptr(GBytes) blob = NULL;
|
g_autoptr(GBytes) blob = NULL;
|
||||||
buf = g_base64_decode (tmp, &bufsz);
|
buf = g_base64_decode (xb_node_get_text (data), &bufsz);
|
||||||
blob = g_bytes_new (buf, bufsz);
|
blob = g_bytes_new (buf, bufsz);
|
||||||
fu_firmware_image_set_bytes (self, blob);
|
fu_firmware_image_set_bytes (self, blob);
|
||||||
|
} else if (data != NULL) {
|
||||||
|
g_autoptr(GBytes) blob = NULL;
|
||||||
|
blob = g_bytes_new (NULL, 0);
|
||||||
|
fu_firmware_image_set_bytes (self, blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* subclassed */
|
/* subclassed */
|
||||||
|
Loading…
Reference in New Issue
Block a user