You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<
8000
script type="application/json" data-target="react-app.embeddedData">{"payload":{"commit":{"oid":"d8f5acbdb9b22106db583e3cbb177d34e6b18eeb","url":"/postgres/postgres/commit/d8f5acbdb9b22106db583e3cbb177d34e6b18eeb","authoredDate":"2024-04-11T13:19:29.000+12:00","committedDate":"2024-04-11T13:23:45.000+12:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eFix potential stack overflow in incremental backup.\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"The user can set RELSEG_SIZE to a high number at compile time, so we\ncan't use it to control the size of an array on the stack: it could be\nmany gigabytes in size. On closer inspection, we don't really need that\nintermediate array anyway. Let's just write directly into the output\narray, and then perform the absolute-\u0026gt;relative adjustment in place.\nThis fixes new code from commit \u003ca class=\"commit-link\" data-hovercard-type=\"commit\" data-hovercard-url=\"https://github.com/postgres/postgres/commit/dc212340058b4e7ecfc5a7a81ec50e7a207bf288/hovercard\" href=\"https://github.com/postgres/postgres/commit/dc212340058b4e7ecfc5a7a81ec50e7a207bf288\"\u003e\u003ctt\u003edc21234\u003c/tt\u003e\u003c/a\u003e.\n\nReviewed-by: Robert Haas \u0026lt;robertmhaas@gmail.com\u0026gt;\nDiscussion: \u003ca href=\"https://postgr.es/m/CA%2BhUKG%2B2hZ0sBztPW4mkLfng0qfkNtAHFUfxOMLizJ0BPmi5%2Bg%40mail.gmail.com\" rel=\"nofollow\"\u003ehttps://postgr.es/m/CA%2BhUKG%2B2hZ0sBztPW4mkLfng0qfkNtAHFUfxOMLizJ0BPmi5%2Bg%40mail.gmail.com\u003c/a\u003e","authors":[{"login":"macdice","displayName":"Thomas Munro","avatarUrl":"https://avatars.githubusercontent.com/u/150350?v=4","path":"/macdice","isGitHub":false}],"committerAttribution":false,"committer":{"login":"macdice","displayName":"Thomas Munro","avatarUrl":"https://avatars.githubusercontent.com/u/150350?v=4","path":"/macdice","isGitHub":false},"parents":["f56a9def71bb1d2ccf4fa01a4d1e082c1063d921"],"globalRelayId":"C_kwDOAA4m0toAKGQ4ZjVhY2JkYjliMjIxMDZkYjU4M2UzY2JiMTc3ZDM0ZTZiMThlZWI","sha1":"f56a9def71bb1d2ccf4fa01a4d1e082c1063d921","sha2":"d8f5acbdb9b22106db583e3cbb177d34e6b18eeb"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":725,"text":"@@ -726,7 +726,8 @@ GetIncrementalFilePath(Oid dboid, Oid spcoid, RelFileNumber relfilenumber,","html":"@@ -726,7 +726,8 @@ GetIncrementalFilePath(Oid dboid, Oid spcoid, RelFileNumber relfilenumber,","displayNoNewLineWarning":false,"position":0,"left":725,"right":725},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":726,"text":" * How should we back up a particular file as part of an incremental backup?","html":" \u003cspan class=pl-c\u003e * How should we back up a particular file as part of an incremental backup?\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":726,"right":726},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":727,"text":" *","html":" \u003cspan class=pl-c\u003e *\u003c/span\u003e","displayNoNewLineWarning":false,"position":2,"left":727,"right":727},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":728,"text":" * If the return value is BACK_UP_FILE_FULLY, caller should back up the whole","html":" \u003cspan class=pl-c\u003e * If the return value is BACK_UP_FILE_FULLY, caller should back up the whole\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":728,"right":728},{"stylingDirective":null,"type":"DELETION","blobLineNumber":729,"text":"- * file just as if this were not an incremental backup.","html":"-\u003cspan class=pl-c\u003e * file just as if this were not an incremental backup.\u003c/span\u003e","displayNoNewLineWarning":false,"position":4,"left":729,"right":728},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":729,"text":"+ * file just as if this were not an incremental backup. The contents of the","html":"+\u003cspan class=pl-c\u003e * file just as if this were not an incremental backup. The contents of the\u003c/span\u003e","displayNoNewLineWarning":false,"position":5,"left":729,"right":729},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":730,"text":"+ * relative_block_numbers array is unspecified in this case.","html":"+\u003cspan class=pl-c\u003e * relative_block_numbers array is unspecified in this case.\u003c/span\u003e","displayNoNewLineWarning":false,"position":6,"left":729,"right":730},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":731,"text":" *","html":" \u003cspan class=pl-c\u003e *\u003c/span\u003e","displayNoNewLineWarning":false,"position":7,"left":730,"right":731},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":732,"text":" * If the return value is BACK_UP_FILE_INCREMENTALLY, caller should include","html":" \u003cspan class=pl-c\u003e * If the return value is BACK_UP_FILE_INCREMENTALLY, caller should include\u003c/span\u003e","displayNoNewLineWarning":false,"position":8,"left":731,"right":732},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":733,"text":" * an incremental file in the backup instead of the entire file. On return,","html":" \u003cspan class=pl-c\u003e * an incremental file in the backup instead of the entire file. On return,\u003c/span\u003e","displayNoNewLineWarning":false,"position":9,"left":732,"right":733},{"stylingDirective":null,"type":"HUNK","blobLineNumber":745,"text":"@@ -745,7 +746,6 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,","html":"@@ -745,7 +746,6 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,","displayNoNewLineWarning":false,"position":10,"left":744,"right":745},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":746,"text":" \t\t\t\t\tBlockNumber *relative_block_numbers,","html":" \t\t\t\t\t\u003cspan class=pl-smi\u003eBlockNumber\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003erelative_block_numbers\u003c/span\u003e,","displayNoNewLineWarning":false,"position":11,"left":745,"right":746},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":747,"text":" \t\t\t\t\tunsigned *truncation_block_length)","html":" \t\t\t\t\t\u003cspan class=pl-smi\u003eunsigned\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003etruncation_block_length\u003c/span\u003e)","displayNoNewLineWarning":false,"position":12,"left":746,"right":747},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":748,"text":" {","html":" {","displayNoNewLineWarning":false,"position":13,"left":747,"right":748},{"stylingDirective":null,"type":"DELETION","blobLineNumber":748,"text":"-\tBlockNumber absolute_block_numbers[RELSEG_SIZE];","html":"-\t\u003cspan class=pl-smi\u003eBlockNumber\u003c/span\u003e \u003cspan class=pl-s1\u003eabsolute_block_numbers\u003c/span\u003e[\u003cspan class=pl-c1\u003eRELSEG_SIZE\u003c/span\u003e];","displayNoNewLineWarning":false,"position":14,"left":748,"right":748},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":749,"text":" \tBlockNumber limit_block;","html":" \t\u003cspan class=pl-smi\u003eBlockNumber\u003c/span\u003e \u003cspan class=pl-s1\u003elimit_block\u003c/span\u003e;","displayNoNewLineWarning":false,"position":15,"left":749,"right":749},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":750,"text":" \tBlockNumber start_blkno;","html":" \t\u003cspan class=pl-smi\u003eBlockNumber\u003c/span\u003e \u003cspan class=pl-s1\u003estart_blkno\u003c/span\u003e;","displayNoNewLineWarning":false,"position":16,"left":750,"right":750},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":751,"text":" \tBlockNumber stop_blkno;","html":" \t\u003cspan class=pl-smi\u003eBlockNumber\u003c/span\u003e \u003cspan class=pl-s1\u003estop_blkno\u003c/span\u003e;","displayNoNewLineWarning":false,"position":17,"left":751,"right":751},{"stylingDirective":null,"type":"HUNK","blobLineNumber":871,"text":"@@ -872,8 +872,13 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,","html":"@@ -872,8 +872,13 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,","displayNoNewLineWarning":false,"position":18,"left":871,"right":871},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":872,"text":" \t\t\t\terrcode(ERRCODE_INTERNAL_ERROR),","html":" \t\t\t\t\u003cspan class=pl-en\u003eerrcode\u003c/span\u003e(\u003cspan class=pl-c1\u003eERRCODE_INTERNAL_ERROR\u003c/span\u003e),","displayNoNewLineWarning":false,"position":19,"left":872,"right":872},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":873,"text":" \t\t\t\terrmsg_internal(\"overflow computing block number bounds for segment %u with size %zu\",","html":" \t\t\t\t\u003cspan class=pl-en\u003eerrmsg_internal\u003c/span\u003e(\u003cspan class=pl-s\u003e\u0026quot;overflow computing block number bounds for segment %u with size %zu\u0026quot;\u003c/span\u003e,","displayNoNewLineWarning":false,"position":20,"left":873,"right":873},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":874,"text":" \t\t\t\t\t\t\t\tsegno, size));","html":" \t\t\t\t\t\t\t\t\u003cspan class=pl-s1\u003esegno\u003c/span\u003e, \u003cspan class=pl-s1\u003esize\u003c/span\u003e));","displayNoNewLineWarning":false,"position":21,"left":874,"right":874},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":875,"text":"+","html":"+","displayNoNewLineWarning":false,"position":22,"left":874,"right":875},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":876,"text":"+\t/*","html":"+\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":23,"left":874,"right":876},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":877,"text":"+\t * This will write *absolute* block numbers into the output array, but","html":"+\u003cspan class=pl-c\u003e\t * This will write *absolute* block numbers into the output array, but\u003c/span\u003e","displayNoNewLineWarning":false,"position":24,"left":874,"right":877},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":878,"text":"+\t * we'll transpose them below.","html":"+\u003cspan class=pl-c\u003e\t * we\u0026#39;ll transpose them below.\u003c/span\u003e","displayNoNewLineWarning":false,"position":25,"left":874,"right":878},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":879,"text":"+\t */","html":"+\u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":26,"left":874,"right":879},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":880,"text":" \tnblocks = BlockRefTableEntryGetBlocks(brtentry, start_blkno, stop_blkno,","html":" \t\u003cspan class=pl-s1\u003enblocks\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eBlockRefTableEntryGetBlocks\u003c/span\u003e(\u003cspan class=pl-s1\u003ebrtentry\u003c/span\u003e, \u003cspan class=pl-s1\u003estart_blkno\u003c/span\u003e, \u003cspan class=pl-s1\u003estop_blkno\u003c/span\u003e,","displayNoNewLineWarning":false,"position":27,"left":875,"right":880},{"stylingDirective":null,"type":"DELETION","blobLineNumber":876,"text":"-\t\t\t\t\t\t\t\t\t\t absolute_block_numbers, RELSEG_SIZE);","html":"-\t\t\t\t\t\t\t\t\t\t \u003cspan class=\"pl-s1 x x-first x-last\"\u003eabsolute_block_numbers\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003eRELSEG_SIZE\u003c/span\u003e);","displayNoNewLineWarning":false,"position":28,"left":876,"right":880},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":881,"text":"+\t\t\t\t\t\t\t\t\t\t relative_block_numbers, RELSEG_SIZE);","html":"+\t\t\t\t\t\t\t\t\t\t \u003cspan class=\"pl-s1 x x-first x-last\"\u003erelative_block_numbers\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003eRELSEG_SIZE\u003c/span\u003e);","displayNoNewLineWarning":false,"position":29,"left":876,"right":881},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":882,"text":" \tAssert(nblocks \u003c= RELSEG_SIZE);","html":" \t\u003cspan class=pl-en\u003eAssert\u003c/span\u003e(\u003cspan class=pl-s1\u003enblocks\u003c/span\u003e \u0026lt;= \u003cspan class=pl-c1\u003eRELSEG_SIZE\u003c/span\u003e);","displayNoNewLineWarning":false,"position":30,"left":877,"right":882},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":883,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":31,"left":878,"right":883},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":884,"text":" \t/*","html":" \t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":32,"left":879,"right":884},{"stylingDirective":null,"type":"HUNK","blobLineNumber":896,"text":"@@ -892,19 +897,22 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,","html":"@@ -892,19 +897,22 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,","displayNoNewLineWarning":false,"position":33,"left":891,"right":896},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":897,"text":" \t\treturn BACK_UP_FILE_FULLY;","html":" \t\t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e \u003cspan class=pl-c1\u003eBACK_UP_FILE_FULLY\u003c/span\u003e;","displayNoNewLineWarning":false,"position":34,"left":892,"right":897},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":898,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":35,"left":893,"right":898},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":899,"text":" \t/*","html":" \t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":36,"left":894,"right":899},{"stylingDirective":null,"type":"DELETION","blobLineNumber":895,"text":"-\t * Looks like we can send an incremental file, so sort the absolute the","html":"-\u003cspan class=\"pl-c\"\u003e\t * Looks like we can send an incremental file, so sort the \u003cspan class=\"x x-first x-last\"\u003eabsolute the\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":37,"left":895,"right":899},{"stylingDirective":null,"type":"DELETION","blobLineNumber":896,"text":"-\t * block numbers and then transpose absolute block numbers to relative","html":"-\u003cspan class=\"pl-c\"\u003e\t * \u003cspan class=\"x x-first x-last\"\u003eblock numbers \u003c/span\u003eand then transpose absolute block numbers to relative\u003c/span\u003e","displayNoNewLineWarning":false,"position":38,"left":896,"right":899},{"stylingDirective":null,"type":"DELETION","blobLineNumber":897,"text":"-\t * block numbers.","html":"-\u003cspan class=\"pl-c\"\u003e\t * \u003cspan class=\"x x-first x-last\"\u003eblock \u003c/span\u003enumbers.\u003c/span\u003e","displayNoNewLineWarning":false,"position":39,"left":897,"right":899},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":900,"text":"+\t * Looks like we can send an incremental file, so sort the block numbers","html":"+\u003cspan class=\"pl-c\"\u003e\t * Looks like we can send an incremental file, so sort the \u003cspan class=\"x x-first x-last\"\u003eblock numbers\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":40,"left":897,"right":900},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":901,"text":"+\t * and then transpose them from absolute block numbers to relative block","html":"+\u003cspan class=\"pl-c\"\u003e\t * and then transpose \u003cspan class=\"x x-first x-last\"\u003ethem from \u003c/span\u003eabsolute block numbers to relative\u003cspan class=\"x x-first x-last\"\u003e block\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":41,"left":897,"right":901},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":902,"text":"+\t * numbers if necessary.","html":"+\u003cspan class=\"pl-c\"\u003e\t * numbers\u003cspan class=\"x x-first x-last\"\u003e if necessary\u003c/span\u003e.\u003c/span\u003e","displayNoNewLineWarning":false,"position":42,"left":897,"right":902},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":903,"text":" \t *","html":" \u003cspan class=pl-c\u003e\t *\u003c/span\u003e","displayNoNewLineWarning":false,"position":43,"left":898,"right":903},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":904,"text":" \t * NB: If the block reference table was using the bitmap representation","html":" \u003cspan class=pl-c\u003e\t * NB: If the block reference table was using the bitmap representation\u003c/span\u003e","displayNoNewLineWarning":false,"position":44,"left":899,"right":904},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":905,"text":" \t * for a given chunk, the block numbers in that chunk will already be","html":" \u003cspan class=pl-c\u003e\t * for a given chunk, the block numbers in that chunk will already be\u003c/span\u003e","displayNoNewLineWarning":false,"position":45,"left":900,"right":905},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":906,"text":" \t * sorted, but when the array-of-offsets representation is used, we can","html":" \u003cspan class=pl-c\u003e\t * sorted, but when the array-of-offsets representation is used, we can\u003c/span\u003e","displayNoNewLineWarning":false,"position":46,"left":901,"right":906},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":907,"text":" \t * receive block numbers here out of order.","html":" \u003cspan class=pl-c\u003e\t * receive block numbers here out of order.\u003c/span\u003e","displayNoNewLineWarning":false,"position":47,"left":902,"right":907},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":908,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":48,"left":903,"right":908},{"stylingDirective":null,"type":"DELETION","blobLineNumber":904,"text":"-\tqsort(absolute_block_numbers, nblocks, sizeof(BlockNumber),","html":"-\t\u003cspan class=\"pl-en\"\u003eqsort\u003c/span\u003e(\u003cspan class=\"pl-s1 x x-first x-last\"\u003eabsolute_block_numbers\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003enblocks\u003c/span\u003e, \u003cspan class=\"pl-k\"\u003esizeof\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eBlockNumber\u003c/span\u003e),","displayNoNewLineWarning":false,"position":49,"left":904,"right":908},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":909,"text":"+\tqsort(relative_block_numbers, nblocks, sizeof(BlockNumber),","html":"+\t\u003cspan class=\"pl-en\"\u003eqsort\u003c/span\u003e(\u003cspan class=\"pl-s1 x x-first x-last\"\u003erelative_block_numbers\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003enblocks\u003c/span\u003e, \u003cspan class=\"pl-k\"\u003esizeof\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eBlockNumber\u003c/span\u003e),","displayNoNewLineWarning":false,"position":50,"left":904,"right":909},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":910,"text":" \t\t compare_block_numbers);","html":" \t\t \u003cspan class=pl-s1\u003ecompare_block_numbers\u003c/span\u003e);","displayNoNewLineWarning":false,"position":51,"left":905,"right":910},{"stylingDirective":null,"type":"DELETION","blobLineNumber":906,"text":"-\tfor (i = 0; i \u003c nblocks; ++i)","html":"-\t\u003cspan class=pl-k\u003efor\u003c/span\u003e (\u003cspan class=pl-s1\u003ei\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e; \u003cspan class=pl-s1\u003ei\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026lt;\u003c/span\u003e \u003cspan class=pl-s1\u003enblocks\u003c/span\u003e; \u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003ei\u003c/span\u003e)","displayNoNewLineWarning":false,"position":52,"left":906,"right":910},{"stylingDirective":null,"type":"DELETION","blobLineNumber":907,"text":"-\t\trelative_block_numbers[i] = absolute_block_numbers[i] - start_blkno;","html":"-\t\t\u003cspan class=pl-s1\u003erelative_block_numbers\u003c/span\u003e[\u003cspan class=pl-s1\u003ei\u003c/span\u003e] \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003eabsolute_block_numbers\u003c/span\u003e[\u003cspan class=pl-s1\u003ei\u003c/span\u003e] \u003cspan class=pl-c1\u003e-\u003c/span\u003e \u003cspan class=pl-s1\u003estart_blkno\u003c/span\u003e;","displayNoNewLineWarning":false,"position":53,"left":907,"right":910},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":911,"text":"+\tif (start_blkno != 0)","html":"+\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003estart_blkno\u003c/span\u003e \u003cspan class=pl-c1\u003e!=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e)","displayNoNewLineWarning":false,"position":54,"left":907,"right":911},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":912,"text":"+\t{","html":"+\t{","displayNoNewLineWarning":false,"position":55,"left":907,"right":912},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":913,"text":"+\t\tfor (i = 0; i \u003c nblocks; ++i)","html":"+\t\t\u003cspan class=pl-k\u003efor\u003c/span\u003e (\u003cspan class=pl-s1\u003ei\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-c1\u003e0\u003c/span\u003e; \u003cspan class=pl-s1\u003ei\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026lt;\u003c/span\u003e \u003cspan class=pl-s1\u003enblocks\u003c/span\u003e; \u003cspan class=pl-c1\u003e++\u003c/span\u003e\u003cspan class=pl-s1\u003ei\u003c/span\u003e)","displayNoNewLineWarning":false,"position":56,"left":907,"right":913},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":914,"text":"+\t\t\trelative_block_numbers[i] -= start_blkno;","html":"+\t\t\t\u003cspan class=pl-s1\u003erelative_block_numbers\u003c/span\u003e[\u003cspan class=pl-s1\u003ei\u003c/span\u003e] \u003cspan class=pl-c1\u003e-=\u003c/span\u003e \u003cspan class=pl-s1\u003estart_blkno\u003c/span\u003e;","displayNoNewLineWarning":false,"position":57,"left":907,"right":914},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":915,"text":"+\t}","html":"+\t}","displayNoNewLineWarning":false,"position":58,"left":907,"right":915},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":916,"text":" \t*num_blocks_required = nblocks;","html":" \t\u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003enum_blocks_required\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003enblocks\u003c/span\u003e;","displayNoNewLineWarning":false,"position":59,"left":908,"right":916},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":917,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":60,"left":909,"right":917},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":918,"text":" \t/*","html":" \t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":61,"left":910,"right":918}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":1120,"linesChanged":26,"newTreeEntry":{"lineCount":1120,"path":"src/backend/backup/basebackup_incremental.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/backup/basebackup_incremental.c","mode":100644},"linesAdded":17,"linesDeleted":9,"path":"src/backend/backup/basebackup_incremental.c","pathDigest":"b3c0b1d097ef054a13bef5bf1637f86097c345ac7b43cc342a454e5bd1eaf4e4","status":"MODIFIED","truncatedReason":null,"oldOid":"f56a9def71bb1d2ccf4fa01a4d1e082c1063d921","newOid":"d8f5acbdb9b22106db583e3cbb177d34e6b18eeb","copilotChatReference":null,"deletedSha":"f56a9def71bb1d2ccf4fa01a4d1e082c1063d921","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/d8f5acbdb9b22106db583e3cbb177d34e6b18eeb","fileTreeExpanded":true,"headerInfo":{"additions":17,"deletions":9,"filesChanged":1,"filesChangedString":"1"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":1,"truncated":false,"byteCount":2644,"lineShownCount":62},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"S-1oPm8TeeqS3WMLtEPjWeqAy73aFFBANCk786VGq7icwcHpNSh-G9f7nYYTuw3OD_z5mK0nGpVLMrucSrqrKA"},"/users/diffview?diff=unified":{"post":"FezLg__fcpm9ZdeaTidCZ4E6kF5slfof8d582P6KL2LCwGJUpeR1aPhDKRfp36zwZEaiexumsMqOxfy3EXYv8g"},"/notifications/thread":{"post":"4tEt4VqhK9ryt25LxNLFcAgy0w_BmECozwqJdHcjvC4dORN1iONmof6ztqI0IqgyqoIFOOs2PTWPLcyuztrLPw"}}},"title":"Fix potential stack overflow in incremental backup. · postgres/postgres@d8f5acb","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}
Fix potential stack overflow in incremental backup.
The user can set RELSEG_SIZE to a high number at compile time, so we
can't use it to control the size of an array on the stack: it could be
many gigabytes in size. On closer inspection, we don't really need that
intermediate array anyway. Let's just write directly into the output
array, and then perform the absolute->relative adjustment in place.
This fixes new code from commit dc21234.
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2B2hZ0sBztPW4mkLfng0qfkNtAHFUfxOMLizJ0BPmi5%2Bg%40mail.gmail.com
0 commit comments