From 13e14a6bfd9f29cbfeab0c5161d2a994f97532e7 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:53:53 +0100 Subject: Update/gnulib 2026 03 (#2247) * Sync with the 202601-stable Gnulib code (4a3650d887) * Ignore more deps stuff in gnulib * Remove autogenerated gnulib files * Ignore more gnulib generated headers --- gl/base64.c | 60 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'gl/base64.c') diff --git a/gl/base64.c b/gl/base64.c index 8a0edd4a..77ee371b 100644 --- a/gl/base64.c +++ b/gl/base64.c @@ -1,5 +1,5 @@ /* base64.c -- Encode binary data using printable characters. - Copyright (C) 1999-2001, 2004-2006, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 1999-2001, 2004-2006, 2009-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -39,10 +39,10 @@ * */ +#define BASE64_INLINE _GL_EXTERN_INLINE #include /* Get prototype. */ -#define BASE64_INLINE _GL_EXTERN_INLINE #include "base64.h" /* Get imalloc. */ @@ -372,13 +372,14 @@ static bool decode_4 (char const *restrict in, idx_t inlen, char *restrict *outp, idx_t *outleft) { - char *out = *outp; if (inlen < 2) return false; if (!isbase64 (in[0]) || !isbase64 (in[1])) return false; + char *out = *outp; + if (*outleft) { *out++ = ((base64_to_int[to_uchar (in[0])] << 2) @@ -466,7 +467,6 @@ base64_decode_ctx (struct base64_decode_context *ctx, const char *restrict in, idx_t inlen, char *restrict out, idx_t *outlen) { - idx_t outleft = *outlen; bool ignore_newlines = ctx != NULL; bool flush_ctx = false; unsigned int ctx_i = 0; @@ -477,6 +477,7 @@ base64_decode_ctx (struct base64_decode_context *ctx, flush_ctx = inlen == 0; } + idx_t outleft = *outlen; while (true) { @@ -505,35 +506,36 @@ base64_decode_ctx (struct base64_decode_context *ctx, { ++in; --inlen; - continue; } + else + { + /* Restore OUT and OUTLEFT. */ + out -= outleft_save - outleft; + outleft = outleft_save; - /* Restore OUT and OUTLEFT. */ - out -= outleft_save - outleft; - outleft = outleft_save; - - { - char const *in_end = in + inlen; - char const *non_nl; - - if (ignore_newlines) - non_nl = get_4 (ctx, &in, in_end, &inlen); - else - non_nl = in; /* Might have nl in this case. */ - - /* If the input is empty or consists solely of newlines (0 non-newlines), - then we're done. Likewise if there are fewer than 4 bytes when not - flushing context and not treating newlines as garbage. */ - if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines)) { - inlen = 0; - break; - } - if (!decode_4 (non_nl, inlen, &out, &outleft)) - break; + char const *in_end = in + inlen; + + char const *non_nl; + if (ignore_newlines) + non_nl = get_4 (ctx, &in, in_end, &inlen); + else + non_nl = in; /* Might have nl in this case. */ + + /* If the input is empty or consists solely of newlines (0 non-newlines), + then we're done. Likewise if there are fewer than 4 bytes when not + flushing context and not treating newlines as garbage. */ + if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines)) + { + inlen = 0; + break; + } + if (!decode_4 (non_nl, inlen, &out, &outleft)) + break; - inlen = in_end - in; - } + inlen = in_end - in; + } + } } *outlen -= outleft; -- cgit v1.2.3-74-g34f1