PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15312
PG VersionUnsupported/Unknown
OSMacosx
Opened2018-08-07 10:52:10+00
Reported byPetru-Florin Mihancea
StatusOpen

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15312
Logged by:          Petru-Florin Mihancea
Email address:      (redacted)
PostgreSQL version: Unsupported/Unknown
Operating system:   Macosx
Description:        

While experimenting with a CodeSonar plugin we develop, we noticed a
potential bug in file "postgres/src/backend/postmaster/pgstat.c" line 2698
function CreateSharedBackendStatus.

/* Create or attach to the shared activity buffer */
BackendActivityBufferSize = mul_size(pgstat_track_activity_query_size,
									 NumBackendStatSlots);
BackendActivityBuffer = (char *)
	ShmemInitStruct("Backend Activity Buffer",
					BackendActivityBufferSize,
					&found);
if (!found)
{
	MemSet(BackendActivityBuffer, 0, size); //HERE

	/* Initialize st_activity pointers. */
	buffer = BackendActivityBuffer;
	for (i = 0; i < NumBackendStatSlots; i++)
	{
		BackendStatusArray[i].st_activity_raw = buffer;
		buffer += pgstat_track_activity_query_size;
	}
}

Shouldn't BackendActivityBufferSize be accessed in the marked line instead
of size? 

Thanks,
Petru Florin Mihancea

Messages

DateAuthorSubject
2018-08-07 10:52:10+00=?utf-8?q?PG_Bug_reporting_form?=BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698
2018-08-07 15:31:21+00Alvaro HerreraRe: BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698
2018-08-07 18:45:22+00Tom LaneRe: BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698