Re: Don't pass NULL pointer to strcmp().

From: Xing Guo <higuoxing(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Junwang Zhao <zhjwpku(at)gmail(dot)com>
Subject: Re: Don't pass NULL pointer to strcmp().
Date: 2023-11-01 13:03:10
Message-ID: CACpMh+D7yZs4t17usc+rmvA1PjwbNqX7+4C+pDoSO++PSCfing@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Aleksander and Junwang,

Thanks for your comments. I have updated the patch accordingly.

Best Regards,
Xing

On Wed, Nov 1, 2023 at 7:44 PM Aleksander Alekseev <aleksander(at)timescale(dot)com>
wrote:

> Hi,
>
> > > I found that there's a nullable pointer being passed to strcmp() and
> > > can make the server crash. It can be reproduced on the latest master
> > > branch by crafting an extension[1]. Patch for fixing it is attatched.
> > >
> > > [1] https://github.com/higuoxing/guc_crash/tree/pg
>
> Thanks for reporting. I can confirm that the issue reproduces on the
> `master` branch and the proposed patch fixes it.
>
> > Can we set a string guc to NULL? If not, `*lconf->variable == NULL` would
> > be unnecessary.
>
> Judging by the rest of the code we better keep it, at least for consistenc.
>
> I see one more place with a similar code in guc.c around line 1472.
> Although I don't have exact steps to trigger a crash I suggest adding
> a similar check there.
>
> --
> Best regards,
> Aleksander Alekseev
>

Attachment Content-Type Size
v2-0001-Don-t-use-strcmp-with-nullable-pointers.patch text/x-patch 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2023-11-01 13:40:15 Re: speed up a logical replica setup
Previous Message Jakub Wartak 2023-11-01 12:56:52 Re: trying again to get incremental backup