Bufmgr possible overflow

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Bufmgr possible overflow
Date: 2023-04-12 12:36:14
Message-ID: CAEudQAr_oWHpZk4uumZijYS362gp4KHAah-yUe08CQY4a4SsOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

IMO I think that commit 31966b1
<https://github.com/postgres/postgres/commit/31966b151e6ab7a6284deab6e8fe5faddaf2ae4c>
has an oversight.

All the logic of the changes are based on the "extend_by" variable, which
is a uint32, but in some places it is using "int", which can lead to an
overflow at some point.

I also take the opportunity to correct another oversight, regarding the
commit dad50f6
<https://github.com/postgres/postgres/commit/dad50f677c42de207168a3f08982ba23c9fc6720>
,
for possible duplicate assignment.
GetLocalBufferDescriptor was called twice.

Taking advantage of this, I promoted a scope reduction for some variables,
which I thought was opportune.

Patch attached.

regards,
Ranier Vilela

Attachment Content-Type Size
001-fix-bufmgr-extend-variable-index.patch application/octet-stream 5.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-04-12 13:08:42 Re: Direct I/O
Previous Message Tom Lane 2023-04-12 12:34:46 Re: v12: ERROR: subplan "InitPlan 2 (returns $4)" was not initialized