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

Commit58651d8

Browse files
committed
Fix compatibility thinko for fstat() on standard streams in win32stat.c
GetFinalPathNameByHandleA() cannot be used in compilation environmentswhere _WIN32_WINNT < 0x0600, meaning at least Windows XP used by somebuildfarm members under MinGW that Postgres still needs to support.This was reported as a compilation warning by the buildfarm, but this isactually worse than the report as the code would have not worked.Instead, this switches to GetFileInformationByHandle() that is able tofail for standard streams and succeed for redirected ones, which is whatwe are looking for herein the code emulating fstat(). We also know thatit is able to work in all the environments still supported, thanks tothe existing logic of win32stat.c.Issue introduced by10260c7, so backpatch down to 14.Reported-by: Justin Pryzby, via buildfarm member jacanaAuthor: Michael PaquierReviewed-by: Juan José Santamaría FlechaDiscussion:https://postgr.es/m/20211129050122.GK17618@telsasoft.comBackpatch-through: 14
1 parent4f8d9d1 commit58651d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/port/win32stat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int
289289
_pgfstat64(intfileno,structstat*buf)
290290
{
291291
HANDLEhFile= (HANDLE)_get_osfhandle(fileno);
292-
charpath[MAX_PATH];
292+
BY_HANDLE_FILE_INFORMATIONfiData;
293293

294294
if (hFile==INVALID_HANDLE_VALUE||buf==NULL)
295295
{
@@ -306,7 +306,7 @@ _pgfstat64(int fileno, struct stat *buf)
306306
if ((fileno==_fileno(stdin)||
307307
fileno==_fileno(stdout)||
308308
fileno==_fileno(stderr))&&
309-
GetFinalPathNameByHandleA(hFile,path,MAX_PATH,VOLUME_NAME_NT)==0)
309+
!GetFileInformationByHandle(hFile,&fiData))
310310
{
311311
memset(buf,0,sizeof(*buf));
312312
buf->st_mode=_S_IFCHR;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp