Incorrect assert in libpqwalreceiver

From: Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Incorrect assert in libpqwalreceiver
Date: 2025-03-09 08:09:24
Message-ID: CA+COZaA_9afJxj9ZuO73U5P7WXP+ZM9NGnZvTDCmBFz0FGP+wA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello hackers,

The libpqrcv_connect function asserts 'Assert(i < sizeof(keys))', where
keys is declared as const char *keys[6];.

However, sizeof(keys) is not the correct way to check the array length (on
my system, for example, it's 48 = 6 * 8 at this callsite, not 6.)

I attached a patch to fix the assert, but I suppose we could also just
remove the assert altogether, since it hasn't been doing anything for at
least 8 years.

Regards,
Jacob

Attachment Content-Type Size
v1-length-assert.patch application/octet-stream 593 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniil Davydov 2025-03-09 11:27:58 Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM
Previous Message Tatsuo Ishii 2025-03-09 06:39:57 Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options