Re: SIGSEGV, FPE fix in pg_controldata

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Ilyasov Ian <ianilyasov(at)outlook(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SIGSEGV, FPE fix in pg_controldata
Date: 2025-02-03 17:59:05
Message-ID: CAPpHfdtLdTtYBLngG5P063Uic_YjAOuvG9JiBOgmv8cZpy2nnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ian,

On Thu, Dec 12, 2024 at 12:23 PM Ilyasov Ian <ianilyasov(at)outlook(dot)com> wrote:
> SIGSEGV was caused by two places in pg_controldata.c where there
> is a work with localtime(&time_tmp));. So I added a check for not NULL.
>
> ....
>
> Where casting second operand in % (XLogSegmentsPerXLogId(wal_segsz_bytes)) to unsigned seems enough. Would be glad to hear your thoughts.

Thank you for catching this. I think catching invalid timestamps is
good except we could use already existing string indicating this and
don't bother translators. Also, I don't think we should change
segment size to uint32 as it's already defined as int in awfully a lot
of places. Additionally WalSegMaxSize is clearly within the 32-bit
integer max value. So, I think we can just adjust the check before
XLByteToSeg(). What do you think?

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v2-0001-Fix-possible-pg_control_data-errors-on-corrupted-.patch application/octet-stream 2.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mahendra Singh Thalor 2025-02-03 18:04:39 Re: Non-text mode for pg_dumpall
Previous Message Andrey Borodin 2025-02-03 17:57:27 Re: Using Expanded Objects other than Arrays from plpgsql