Re: BUG #19702: decode() accepts Base64 payload after terminal padding

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, imchifan(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19702: decode() accepts Base64 payload after terminal padding
Date: 2026-11-13 17:49:08
Message-ID: CAD21AoAY8vVS-xg=+Mg25Fppf3mGjOXJNjgoZvAudfg0XCv2WA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Nov 12, 2026 at 4:00 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>
> > On 10 Nov 2026, at 10:23, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> >> On 9 Nov 2026, at 23:43, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> >> While I agree that we don't backpatch it to v18 or older, I think it
> >> (or at least the base64url part) should go into v19 as well. v19 is
> >> still in RC and base64url is new in v19, so there are no existing
> >> users relying on the current behavior, and it would be better to make
> >> base64url and base32hex consistent before the release.
> >
> > That's a good point, I'll prepare a backpatch for 19 for the relevant portions.
>
> The attached is a patch against master for the full fix, and a cut-down version
> fixing just base64url for v19, I thinmk that's what we can do for 19 at this
> point. What do you think about this one?

Thank you for updating the patches. I think the following conditions
can be simplified:

---
+ if ((!url && !end) || (url && (!end || pos != 3)))

to

if (!end || (url && pos != 3))

---
+ if ((!url && c > 0 && c < 127) || (url && c > 0 && c < 127 && !end))

to

if (c > 0 && c < 127 && !(url && end))

The rest looks good to me.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-11-13 18:43:31 Re: BUG #19600: pgcrypto crypt() can return text with invalid encoding
Previous Message Srinath Reddy Sadipiralla 2026-11-13 16:40:03 Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"