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

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix misuse use of pg_b64_encode function (contrib/postgres_fdw/connection.c)
Date: 2025-01-16 01:12:51
Message-ID: CAEudQAq-3yHsSdWoOOaw+gAQYgPMpMGuB5pt2yCXgv-YuxG2Hg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

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.

best regards,
Ranier Vilela

[0] I think the most correct would be *or* not *and* word?

Attachment Content-Type Size
fix-misuse-function-pg_b64_encode.patch application/octet-stream 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Anton A. Melnikov 2025-01-16 01:15:31 Re: Change GUC hashtable to use simplehash?
Previous Message Noah Misch 2025-01-16 01:00:51 Re: An improvement of ProcessTwoPhaseBuffer logic