Skip to content

Commit

Permalink
Win32: fix 'lstat("dir/")' with long paths
Browse files Browse the repository at this point in the history
Use a suffciently large buffer to strip the trailing slash.

Signed-off-by: Karsten Blees <[email protected]>
  • Loading branch information
kblees authored and dscho committed Nov 22, 2024
1 parent 4bd1b69 commit 493ecb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ static int do_lstat(int follow, const char *file_name, struct stat *buf)
static int do_stat_internal(int follow, const char *file_name, struct stat *buf)
{
size_t namelen;
char alt_name[PATH_MAX];
char alt_name[MAX_LONG_PATH];

if (!do_lstat(follow, file_name, buf))
return 0;
Expand All @@ -1024,7 +1024,7 @@ static int do_stat_internal(int follow, const char *file_name, struct stat *buf)
return -1;
while (namelen && file_name[namelen-1] == '/')
--namelen;
if (!namelen || namelen >= PATH_MAX)
if (!namelen || namelen >= MAX_LONG_PATH)
return -1;

memcpy(alt_name, file_name, namelen);
Expand Down

0 comments on commit 493ecb6

Please sign in to comment.