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
9b2397d5
Commit
9b2397d5
authored
Nov 15, 2017
by
Piotr Caban
Committed by
Alexandre Julliard
Nov 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fix read() behaviour on "no console" file descriptors.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
677301a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
file.c
dlls/msvcrt/file.c
+16
-4
file.c
dlls/msvcrt/tests/file.c
+16
-0
No files found.
dlls/msvcrt/file.c
View file @
9b2397d5
...
...
@@ -2892,6 +2892,7 @@ static int read_i(int fd, ioinfo *fdinfo, void *buf, unsigned int count)
else
{
TRACE
(
":failed-last error (%d)
\n
"
,
GetLastError
());
msvcrt_set_errno
(
GetLastError
());
return
-
1
;
}
}
...
...
@@ -2906,8 +2907,16 @@ static int read_i(int fd, ioinfo *fdinfo, void *buf, unsigned int count)
*/
int
CDECL
MSVCRT__read
(
int
fd
,
void
*
buf
,
unsigned
int
count
)
{
ioinfo
*
info
=
get_ioinfo
(
fd
);
int
num_read
=
read_i
(
fd
,
info
,
buf
,
count
);
ioinfo
*
info
;
int
num_read
;
if
(
fd
==
MSVCRT_NO_CONSOLE_FD
)
{
*
MSVCRT__errno
()
=
MSVCRT_EBADF
;
return
-
1
;
}
info
=
get_ioinfo
(
fd
);
num_read
=
read_i
(
fd
,
info
,
buf
,
count
);
release_ioinfo
(
info
);
return
num_read
;
}
...
...
@@ -4291,9 +4300,12 @@ MSVCRT_size_t CDECL MSVCRT__fread_nolock(void *ptr, MSVCRT_size_t size, MSVCRT_s
{
int
i
;
if
(
!
file
->
_cnt
&&
rcnt
<
MSVCRT_BUFSIZ
&&
(
file
->
_flag
&
(
MSVCRT__IOMYBUF
|
MSVCRT__USERBUF
)))
{
file
->
_cnt
=
MSVCRT__read
(
file
->
_file
,
file
->
_base
,
file
->
_bufsiz
);
i
=
MSVCRT__read
(
file
->
_file
,
file
->
_base
,
file
->
_bufsiz
);
file
->
_ptr
=
file
->
_base
;
i
=
(
file
->
_cnt
<
rcnt
)
?
file
->
_cnt
:
rcnt
;
if
(
i
!=
-
1
)
{
file
->
_cnt
=
i
;
if
(
i
>
rcnt
)
i
=
rcnt
;
}
/* If the buffer fill reaches eof but fread wouldn't, clear eof. */
if
(
i
>
0
&&
i
<
file
->
_cnt
)
{
get_ioinfo_nolock
(
file
->
_file
)
->
wxflag
&=
~
WX_ATEOF
;
...
...
dlls/msvcrt/tests/file.c
View file @
9b2397d5
...
...
@@ -1528,6 +1528,7 @@ static void test_invalid_stdin_child( void )
HANDLE
handle
;
ioinfo
*
info
;
int
ret
;
char
c
;
errno
=
0xdeadbeef
;
handle
=
(
HANDLE
)
_get_osfhandle
(
STDIN_FILENO
);
...
...
@@ -1541,6 +1542,21 @@ static void test_invalid_stdin_child( void )
ok
(
stdin
->
_file
==
-
2
,
"stdin->_file = %d
\n
"
,
stdin
->
_file
);
errno
=
0xdeadbeef
;
ret
=
fread
(
&
c
,
1
,
1
,
stdin
);
ok
(
!
ret
,
"fread(stdin) returned %d
\n
"
,
ret
);
ok
(
errno
==
EBADF
,
"errno = %d
\n
"
,
errno
);
errno
=
0xdeadbeef
;
ret
=
read
(
-
2
,
&
c
,
1
);
ok
(
ret
==
-
1
,
"read(-2) returned %d
\n
"
,
ret
);
ok
(
errno
==
EBADF
,
"errno = %d
\n
"
,
errno
);
errno
=
0xdeadbeef
;
ret
=
read
(
STDIN_FILENO
,
&
c
,
1
);
ok
(
ret
==
-
1
,
"read(STDIN_FILENO) returned %d
\n
"
,
ret
);
ok
(
errno
==
EBADF
,
"errno = %d
\n
"
,
errno
);
errno
=
0xdeadbeef
;
ret
=
fclose
(
stdin
);
ok
(
ret
==
-
1
,
"fclose(stdin) returned %d
\n
"
,
ret
);
ok
(
errno
==
EBADF
,
"errno = %d
\n
"
,
errno
);
...
...
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