From: Philip Withnall Date: Mon, 3 Aug 2026 15:30:28 +0000 (+0100) Subject: ostree-blob-reader: Add error handling for invalid base64 blobs X-Git-Tag: archive/raspbian/2026.4-1+rpi1^2~9^2~1^2~6^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=82d76f002a55163527cefcd8e7e964fa3cc62e7a;p=ostree.git ostree-blob-reader: Add error handling for invalid base64 blobs One cannot base64 decode the empty string, so catch that case (which can happen if asked to load a malformed key file) early before it causes an assertion failure inside GLib. Signed-off-by: Philip Withnall --- diff --git a/src/libostree/ostree-blob-reader-base64.c b/src/libostree/ostree-blob-reader-base64.c index 6faa4820..2a621822 100644 --- a/src/libostree/ostree-blob-reader-base64.c +++ b/src/libostree/ostree-blob-reader-base64.c @@ -71,9 +71,16 @@ ostree_blob_reader_base64_read_blob (OstreeBlobReader *self, GCancellable *cance if (line == NULL) return NULL; + else if (len == 0) + { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, + "Invalid base64 blob format"); + return NULL; + } gsize n_elements; g_base64_decode_inplace (line, &n_elements); + g_assert (n_elements <= len); explicit_bzero (line + n_elements, len - n_elements); return g_bytes_new_take (g_steal_pointer (&line), n_elements);