Re: Fix misuse use of pg_b64_encode function (contrib/postgres_fdw/connection.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix misuse use of pg_b64_encode function (contrib/postgres_fdw/connection.c)
Date: 2025-01-17 11:00:39
Message-ID: CAEudQAqOAAxFEN4ahpGyptOvJkENCJVi_HsMc9oQaSMCfNVhyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sex., 17 de jan. de 2025 às 05:11, Peter Eisentraut <peter(at)eisentraut(dot)org>
escreveu:

> On 16.01.25 11:23, Ranier Vilela wrote:
> >
> >
> > Em qui., 16 de jan. de 2025 às 05:07, Peter Eisentraut
> > <peter(at)eisentraut(dot)org <mailto:peter(at)eisentraut(dot)org>> escreveu:
> >
> > On 16.01.25 02:12, Ranier Vilela wrote:
> > > Per Coverity.
> > >
> > > CID 1590024: (CHECKED_RETURN)
> > > Calling "pg_b64_encode" without checking return value (as is done
> > > elsewhere 8 out of 10 times).
> > >
> > > The function *pg_b64_encode* has in the comments:
> > > [0] "and -1 in the event of an error"
> > >
> > > So, the function can fail.
> > > All other calls check the return, In this case it could not be
> > different.
> > >
> > > Fix by checking the return and reporting a message to the user,
> > > in case of failure.
> >
> > Thanks, fixed. (I changed the ereports to elogs, which is how other
> > call sites do it.)
> >
> > Thank you.
> >
> >
> > I also fixed a related problem in the pg_b64_decode() calls in libpq.
> >
> > Maybe we could put a pg_nodiscard attribute on pg_b64_encode() and
> > pg_b64_decode()?
> >
> > +1
>
> done
>
Thanks Peter.

best regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vladimir Sitnikov 2025-01-17 11:08:15 Add a property to automatically suspend portals as they produce given number of bytes
Previous Message Dean Rasheed 2025-01-17 10:44:03 Re: Adding OLD/NEW support to RETURNING