Skip to content

Commit faee318

Browse files
committed
Fix off_t overflow in pg_basebackup on Windows.
walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh <davinder.singh@enterprisedb.com> Reported-by: Jakub Wartak <jakub.wartak@enterprisedb.com> Discussion: https://postgr.es/m/CAKZiRmyM4YnokK6Oenw5JKwAQ3rhP0YTz2T-tiw5dAQjGRXE3Q%40mail.gmail.com
1 parent af109e3 commit faee318

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/bin/pg_basebackup/receivelog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static bool
192192
close_walfile(StreamCtl *stream, XLogRecPtr pos)
193193
{
194194
char *fn;
195-
off_t currpos;
195+
pgoff_t currpos;
196196
int r;
197197
char walfile_name[MAXPGPATH];
198198

src/bin/pg_basebackup/walmethods.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ const WalWriteMethodOps WalTarMethodOps = {
691691
typedef struct TarMethodFile
692692
{
693693
Walfile base;
694-
off_t ofs_start; /* Where does the *header* for this file start */
694+
pgoff_t ofs_start; /* Where does the *header* for this file start */
695695
char header[TAR_BLOCK_SIZE];
696696
size_t pad_to_size;
697697
} TarMethodFile;

src/bin/pg_basebackup/walmethods.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct WalWriteMethod WalWriteMethod;
1717
typedef struct
1818
{
1919
WalWriteMethod *wwmethod;
20-
off_t currpos;
20+
pgoff_t currpos;
2121
char *pathname;
2222

2323
/*

0 commit comments

Comments
 (0)