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

Commitf4fd532

Browse files
macdiceadunstan
authored andcommitted
Fix readlink() for non-PostgreSQL junction points on Windows.
Since commitc5cb8f3 taught stat() to follow symlinks, and since initdbuses pg_mkdir_p(), and that examines parent directories, our humblereadlink() implementation can now be exposed to junction points not ofPostgreSQL origin. Those might be corrupted by our naive path mangling,which doesn't really understand NT paths in general.Simply decline to transform paths that don't look like a drive absolutepath. That means that readlink() returns the NT path directly whenchecking a parent directory of PGDATA that happen to point to a driveusing "rooted" format. That works for the purposes of our stat()emulation.Reported-by: Roman Zharkov <r.zharkov@postgrespro.ru>Reviewed-by: Roman Zharkov <r.zharkov@postgrespro.ru>Discussion:https://postgr.es/m/4590c37927d7b8ee84f9855d83229018%40postgrespro.ruDiscussion:https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.comBackpatched commitf71007f as above by Thomas Munro into releases 13 thru 15Discussion:https://postgr.es/m/CA+hUKGLbnv+pe3q1fYOVkLD3pMra7GuihfMxUN-1831YH9RYQg@mail.gmail.com
1 parent9f1c674 commitf4fd532

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎src/port/dirmod.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,21 @@ pgreadlink(const char *path, char *buf, size_t size)
351351
}
352352

353353
/*
354-
* If the path starts with "\??\", which it will do in most (all?) cases,
355-
* strip those out.
354+
* If the path starts with "\??\" followed by a "drive absolute" path
355+
* (known to Windows APIs as RtlPathTypeDriveAbsolute), then strip that
356+
* prefix. This undoes some of the transformation performed by
357+
* pqsymlink(), to get back to a format that users are used to seeing. We
358+
* don't know how to transform other path types that might be encountered
359+
* outside PGDATA, so we just return them directly.
356360
*/
357-
if (r>4&&strncmp(buf,"\\??\\",4)==0)
361+
if (r >=7&&
362+
buf[0]=='\\'&&
363+
buf[1]=='?'&&
364+
buf[2]=='?'&&
365+
buf[3]=='\\'&&
366+
isalpha(buf[4])&&
367+
buf[5]==':'&&
368+
buf[6]=='\\')
358369
{
359370
memmove(buf,buf+4,strlen(buf+4)+1);
360371
r-=4;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp