Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28328ec

Browse files
Fix overflow danger in SampleHeapTupleVisible()
68d9662 made HeapScanDesc->rs_ntuples unsigned but neglected tochange how it was being used in SampleHeapTupleVisible().Return early if rs_ntuples is 0 to avoid overflowing and incorrectlyexecuting the loop code in SampleHeapTupleVisible().Reported-by: Ranier VilelaDiscussion:https://postgr.es/m/CAEudQAot_xQoZyPZjpj1aBUPrPykY5mOPHGyvfe%3Djz%2BWowdA3A%40mail.gmail.com
1 parent68d9662 commit28328ec

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/backend/access/heap/heapam_handler.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,12 @@ SampleHeapTupleVisible(TableScanDesc scan, Buffer buffer,
25772577

25782578
if (scan->rs_flags&SO_ALLOW_PAGEMODE)
25792579
{
2580+
uint32start,
2581+
end;
2582+
2583+
if (hscan->rs_ntuples==0)
2584+
return false;
2585+
25802586
/*
25812587
* In pageatatime mode, heap_prepare_pagescan() already did visibility
25822588
* checks, so just look at the info it left in rs_vistuples[].
@@ -2586,12 +2592,12 @@ SampleHeapTupleVisible(TableScanDesc scan, Buffer buffer,
25862592
* in increasing order, but it's not clear that there would be enough
25872593
* gain to justify the restriction.
25882594
*/
2589-
intstart=0,
2590-
end=hscan->rs_ntuples-1;
2595+
start=0;
2596+
end=hscan->rs_ntuples-1;
25912597

25922598
while (start <=end)
25932599
{
2594-
intmid= (start+end) /2;
2600+
uint32mid= (start+end) /2;
25952601
OffsetNumbercuroffset=hscan->rs_vistuples[mid];
25962602

25972603
if (tupoffset==curoffset)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp