Collin Funk <[email protected]> writes:

> That is my hypothesis at least, will need to write a patch to test it.

Looks like my hypothesis was correct. I ran the CI with the attached
patch, and everything passes.

I'll hold off pushing until Pádraig checks it. Since he may want to
revisit his previous commit and handle things differently.

Collin

>From 78f43aa524e6fa7d1e39f68a81d9894b8d629424 Mon Sep 17 00:00:00 2001
Message-ID: <78f43aa524e6fa7d1e39f68a81d9894b8d629424.1757830015.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sat, 13 Sep 2025 22:59:05 -0700
Subject: [PATCH] basenc: fix an uninitialized index when decoding an empty
 file

* src/basenc.c (base64_decode_ctx_init_wrapper)
(base64url_decode_ctx_init_wrapper)
(base32_decode_ctx_init_wrapper)
(base32hex_decode_ctx_init_wrapper): Initialize ctx->i to zero.
Fixes https://bugs.gnu.org/79444
---
 src/basenc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/basenc.c b/src/basenc.c
index 5976b1aa6..49740a47b 100644
--- a/src/basenc.c
+++ b/src/basenc.c
@@ -393,6 +393,7 @@ static void
 base64_decode_ctx_init_wrapper (struct base_decode_context *ctx)
 {
   base64_decode_ctx_init (&ctx->ctx.base64);
+  ctx->i = 0;
 }
 
 static bool
@@ -449,6 +450,7 @@ static void
 base64url_decode_ctx_init_wrapper (struct base_decode_context *ctx)
 {
   base64_decode_ctx_init (&ctx->ctx.base64);
+  ctx->i = 0;
   init_inbuf (ctx);
 }
 
@@ -497,6 +499,7 @@ static void
 base32_decode_ctx_init_wrapper (struct base_decode_context *ctx)
 {
   base32_decode_ctx_init (&ctx->ctx.base32);
+  ctx->i = 0;
 }
 
 static bool
@@ -576,6 +579,7 @@ static void
 base32hex_decode_ctx_init_wrapper (struct base_decode_context *ctx)
 {
   base32_decode_ctx_init (&ctx->ctx.base32);
+  ctx->i = 0;
   init_inbuf (ctx);
 }
 
-- 
2.51.0

Reply via email to