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

Commit1e01374

Browse files
committed
Fix overflow in Windows replacement pg_pread/pg_pwrite.
When calling the Windows file I/O APIs there is an implicit conversionfrom size_t to DWORD, which could overflow. Clamp the size at 1GB toavoid that.Not a really a live bug as we don't expect anything in PostgreSQL tocall with such large values.Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://postgr.es/m/1672202.1703441340%40sss.pgh.pa.us
1 parent653b55b commit1e01374

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

‎src/port/win32pread.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pg_pread(int fd, void *buf, size_t size, off_t offset)
3030
return-1;
3131
}
3232

33+
/* Avoid overflowing DWORD. */
34+
size=Min(size,1024*1024*1024);
35+
3336
/* Note that this changes the file position, despite not using it. */
3437
overlapped.Offset=offset;
3538
if (!ReadFile(handle,buf,size,&result,&overlapped))

‎src/port/win32pwrite.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
3030
return-1;
3131
}
3232

33+
/* Avoid overflowing DWORD. */
34+
size=Min(size,1024*1024*1024);
35+
3336
/* Note that this changes the file position, despite not using it. */
3437
overlapped.Offset=offset;
3538
if (!WriteFile(handle,buf,size,&result,&overlapped))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp