Avoid overflowed array index (src/backend/utils/activity/pgstat.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Avoid overflowed array index (src/backend/utils/activity/pgstat.c)
Date: 2024-09-04 18:14:34
Message-ID: CAEudQApBfq6SP4A1EcYBn_dW=Kn_1O42o4HavVECmKVcws4KxA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

Per Coverity.

The commit 7949d95 <http://7949d9594582ab49dee221e1db1aa5401ace49d4>, left
out an oversight.

The report is:
CID 1559468: (#1 of 1): Overflowed array index read (INTEGER_OVERFLOW)

I think that Coverity is right.
In the function *pgstat_read_statsfile* It is necessary to first check
whether it is the most restrictive case.

Otherwise, if PgStat_Kind is greater than 11, a negative index may occur.

Patch attached.

best regards,
Ranier Vilela

Attachment Content-Type Size
0001-avoid-overflowed-array-index-pgstat.patch application/octet-stream 816 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-09-04 18:21:00 Re: gamma() and lgamma() functions
Previous Message Tom Lane 2024-09-04 18:06:06 Re: Fix possible resource leaks (src/backend/replication/logical/conflict.c)