Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
bcf4467b
Commit
bcf4467b
authored
Dec 27, 2012
by
Piotr Caban
Committed by
Alexandre Julliard
Dec 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Return error in stat function when path is specified with trailing slash character.
parent
9dbd1969
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
10 deletions
+48
-10
file.c
dlls/msvcrt/file.c
+24
-10
file.c
dlls/msvcrt/tests/file.c
+24
-0
No files found.
dlls/msvcrt/file.c
View file @
bcf4467b
...
...
@@ -2159,10 +2159,20 @@ int CDECL MSVCRT_stat64(const char* path, struct MSVCRT__stat64 * buf)
TRACE
(
":file (%s) buf(%p)
\n
"
,
path
,
buf
);
plen
=
strlen
(
path
);
while
(
plen
&&
path
[
plen
-
1
]
==
' '
)
plen
--
;
if
(
plen
&&
(
path
[
plen
-
1
]
==
'\\'
||
path
[
plen
-
1
]
==
'/'
))
{
*
MSVCRT__errno
()
=
MSVCRT_ENOENT
;
return
-
1
;
}
if
(
!
GetFileAttributesExA
(
path
,
GetFileExInfoStandard
,
&
hfi
))
{
TRACE
(
"failed (%d)
\n
"
,
GetLastError
());
msvcrt_set_errno
(
ERROR_FILE_NOT_FOUND
)
;
*
MSVCRT__errno
()
=
MSVCRT_ENOENT
;
return
-
1
;
}
...
...
@@ -2178,11 +2188,8 @@ int CDECL MSVCRT_stat64(const char* path, struct MSVCRT__stat64 * buf)
else
buf
->
st_dev
=
buf
->
st_rdev
=
MSVCRT__getdrive
()
-
1
;
plen
=
strlen
(
path
);
/* Dir, or regular file? */
if
((
hfi
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
(
path
[
plen
-
1
]
==
'\\'
))
if
(
hfi
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
mode
|=
(
MSVCRT__S_IFDIR
|
ALL_S_IEXEC
);
else
{
...
...
@@ -2252,10 +2259,20 @@ int CDECL MSVCRT__wstat64(const MSVCRT_wchar_t* path, struct MSVCRT__stat64 * bu
TRACE
(
":file (%s) buf(%p)
\n
"
,
debugstr_w
(
path
),
buf
);
plen
=
strlenW
(
path
);
while
(
plen
&&
path
[
plen
-
1
]
==
' '
)
plen
--
;
if
(
plen
&&
(
path
[
plen
-
1
]
==
'\\'
||
path
[
plen
-
1
]
==
'/'
))
{
*
MSVCRT__errno
()
=
MSVCRT_ENOENT
;
return
-
1
;
}
if
(
!
GetFileAttributesExW
(
path
,
GetFileExInfoStandard
,
&
hfi
))
{
TRACE
(
"failed (%d)
\n
"
,
GetLastError
());
msvcrt_set_errno
(
ERROR_FILE_NOT_FOUND
)
;
*
MSVCRT__errno
()
=
MSVCRT_ENOENT
;
return
-
1
;
}
...
...
@@ -2267,11 +2284,8 @@ int CDECL MSVCRT__wstat64(const MSVCRT_wchar_t* path, struct MSVCRT__stat64 * bu
else
buf
->
st_dev
=
buf
->
st_rdev
=
MSVCRT__getdrive
()
-
1
;
plen
=
strlenW
(
path
);
/* Dir, or regular file? */
if
((
hfi
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
(
path
[
plen
-
1
]
==
'\\'
))
if
(
hfi
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
mode
|=
(
MSVCRT__S_IFDIR
|
ALL_S_IEXEC
);
else
{
...
...
dlls/msvcrt/tests/file.c
View file @
bcf4467b
...
...
@@ -1444,6 +1444,11 @@ static void test_stat(void)
ok
(
buf
.
st_nlink
==
1
,
"st_nlink is %d, expected 1
\n
"
,
buf
.
st_nlink
);
ok
(
buf
.
st_size
==
0
,
"st_size is %d, expected 0
\n
"
,
buf
.
st_size
);
errno
=
0xdeadbeef
;
ret
=
stat
(
"stat.tst
\\
"
,
&
buf
);
ok
(
ret
==
-
1
,
"stat returned %d
\n
"
,
ret
);
ok
(
errno
==
ENOENT
,
"errno = %d
\n
"
,
errno
);
close
(
fd
);
remove
(
"stat.tst"
);
}
...
...
@@ -1483,6 +1488,25 @@ static void test_stat(void)
}
else
skip
(
"pipe failed with errno %d
\n
"
,
errno
);
/* Tests for directory */
if
(
mkdir
(
"stat.tst"
)
==
0
)
{
ret
=
stat
(
"stat.tst "
,
&
buf
);
ok
(
!
ret
,
"stat(directory) failed: errno=%d
\n
"
,
errno
);
ok
((
buf
.
st_mode
&
_S_IFMT
)
==
_S_IFDIR
,
"bad format = %06o
\n
"
,
buf
.
st_mode
);
ok
((
buf
.
st_mode
&
0777
)
==
0777
,
"bad st_mode = %06o
\n
"
,
buf
.
st_mode
);
ok
(
buf
.
st_dev
==
buf
.
st_rdev
,
"st_dev (%d) and st_rdev (%d) differ
\n
"
,
buf
.
st_dev
,
buf
.
st_rdev
);
ok
(
buf
.
st_nlink
==
1
,
"st_nlink is %d, expected 1
\n
"
,
buf
.
st_nlink
);
errno
=
0xdeadbeef
;
ret
=
stat
(
"stat.tst
\\
"
,
&
buf
);
ok
(
ret
==
-
1
,
"stat returned %d
\n
"
,
ret
);
ok
(
errno
==
ENOENT
,
"errno = %d
\n
"
,
errno
);
rmdir
(
"stat.tst"
);
}
else
skip
(
"mkdir failed with errno %d
\n
"
,
errno
);
}
static
const
char
*
pipe_string
=
"Hello world"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment