mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
msvcrt: Fix parameter validation in _stat64 function.
This commit is contained in:
parent
0988938d0f
commit
024ece50e8
@ -2684,7 +2684,8 @@ int CDECL MSVCRT_stat64(const char* path, struct MSVCRT__stat64 * buf)
|
||||
while (plen && path[plen-1]==' ')
|
||||
plen--;
|
||||
|
||||
if (plen && (path[plen-1]=='\\' || path[plen-1]=='/'))
|
||||
if (plen && (plen<2 || path[plen-2]!=':') &&
|
||||
(path[plen-1]==':' || path[plen-1]=='\\' || path[plen-1]=='/'))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_ENOENT;
|
||||
return -1;
|
||||
@ -2784,7 +2785,8 @@ int CDECL MSVCRT__wstat64(const MSVCRT_wchar_t* path, struct MSVCRT__stat64 * bu
|
||||
while (plen && path[plen-1]==' ')
|
||||
plen--;
|
||||
|
||||
if(plen && (path[plen-1]=='\\' || path[plen-1]=='/'))
|
||||
if(plen && (plen<2 || path[plen-2]!=':') &&
|
||||
(path[plen-1]==':' || path[plen-1]=='\\' || path[plen-1]=='/'))
|
||||
{
|
||||
*MSVCRT__errno() = MSVCRT_ENOENT;
|
||||
return -1;
|
||||
|
@ -1907,6 +1907,16 @@ static void test_stat(void)
|
||||
}
|
||||
else
|
||||
skip("mkdir failed with errno %d\n", errno);
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
ret = stat("c:", &buf);
|
||||
ok(ret == -1, "stat returned %d\n", ret);
|
||||
ok(errno == ENOENT, "errno = %d\n", errno);
|
||||
|
||||
ret = stat("c:/", &buf);
|
||||
ok(!ret, "stat returned %d\n", ret);
|
||||
ok(buf.st_dev == 2, "st_dev = %d\n", buf.st_dev);
|
||||
ok(buf.st_rdev == 2, "st_rdev = %d\n", buf.st_rdev);
|
||||
}
|
||||
|
||||
static const char* pipe_string="Hello world";
|
||||
|
Loading…
Reference in New Issue
Block a user