ginRedoRecompress-asserts-v2.patch

application/octet-stream

Filename: ginRedoRecompress-asserts-v2.patch
Type: application/octet-stream
Part: 0
Message: Re: Bug in ginRedoRecompress that causes opaque data on page to be overrun

Patch

Format: unified
Series: patch v2
File+
src/backend/access/gin/ginxlog.c 3 0
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 7a1e94a1d56..52d84a2c207 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -276,6 +276,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
 				break;
 
 			case GIN_SEGMENT_INSERT:
+				Assert(segptr + newsegsize + szleft <= PageGetSpecialPointer(page));
 				/* make room for the new segment */
 				memmove(segptr + newsegsize, segptr, szleft);
 				/* copy the new segment in place */
@@ -285,6 +286,8 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
 				break;
 
 			case GIN_SEGMENT_REPLACE:
+				Assert(segptr + newsegsize + (szleft - segsize) <= PageGetSpecialPointer(page));
+				Assert(segptr + szleft <= PageGetSpecialPointer(page));
 				/* shift the segments that follow */
 				memmove(segptr + newsegsize,
 						segptr + segsize,