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

Commit332f02f

Browse files
committed
Use FLEXIBLE_ARRAY_MEMBER in Windows-specific code.
Be a tad more paranoid about overlength input, too.
1 parent82a532b commit332f02f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/port/dirmod.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ typedef struct
143143
WORDSubstituteNameLength;
144144
WORDPrintNameOffset;
145145
WORDPrintNameLength;
146-
WCHARPathBuffer[1];
146+
WCHARPathBuffer[FLEXIBLE_ARRAY_MEMBER];
147147
}REPARSE_JUNCTION_DATA_BUFFER;
148148

149149
#defineREPARSE_JUNCTION_DATA_BUFFER_HEADER_SIZE \
@@ -160,7 +160,7 @@ pgsymlink(const char *oldpath, const char *newpath)
160160
{
161161
HANDLEdirhandle;
162162
DWORDlen;
163-
charbuffer[MAX_PATH*sizeof(WCHAR)+sizeof(REPARSE_JUNCTION_DATA_BUFFER)];
163+
charbuffer[MAX_PATH*sizeof(WCHAR)+offsetof(REPARSE_JUNCTION_DATA_BUFFER,PathBuffer)];
164164
charnativeTarget[MAX_PATH];
165165
char*p=nativeTarget;
166166
REPARSE_JUNCTION_DATA_BUFFER*reparseBuf= (REPARSE_JUNCTION_DATA_BUFFER*)buffer;
@@ -174,10 +174,10 @@ pgsymlink(const char *oldpath, const char *newpath)
174174
return-1;
175175

176176
/* make sure we have an unparsed native win32 path */
177-
if (memcmp("\\??\\",oldpath,4))
178-
sprintf(nativeTarget,"\\??\\%s",oldpath);
177+
if (memcmp("\\??\\",oldpath,4)!=0)
178+
snprintf(nativeTarget,sizeof(nativeTarget),"\\??\\%s",oldpath);
179179
else
180-
strcpy(nativeTarget,oldpath);
180+
strlcpy(nativeTarget,oldpath,sizeof(nativeTarget));
181181

182182
while ((p=strchr(p,'/'))!=NULL)
183183
*p++='\\';
@@ -239,7 +239,7 @@ pgreadlink(const char *path, char *buf, size_t size)
239239
{
240240
DWORDattr;
241241
HANDLEh;
242-
charbuffer[MAX_PATH*sizeof(WCHAR)+sizeof(REPARSE_JUNCTION_DATA_BUFFER)];
242+
charbuffer[MAX_PATH*sizeof(WCHAR)+offsetof(REPARSE_JUNCTION_DATA_BUFFER,PathBuffer)];
243243
REPARSE_JUNCTION_DATA_BUFFER*reparseBuf= (REPARSE_JUNCTION_DATA_BUFFER*)buffer;
244244
DWORDlen;
245245
intr;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp