]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
basenc: fix an uninitialized index when decoding an empty file
authorCollin Funk <collin.funk1@gmail.com>
Sun, 14 Sep 2025 05:59:05 +0000 (22:59 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 14 Sep 2025 16:30:16 +0000 (09:30 -0700)
* 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

index 5976b1aa68bf0f2ec26bc4c60605905079bea77b..49740a47b1e9fa4c63de1603058d54094324e34f 100644 (file)
@@ -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);
 }