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
b4c1c67e
Commit
b4c1c67e
authored
Oct 26, 2006
by
Duane Clark
Committed by
Alexandre Julliard
Oct 27, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fix fread on large buffers in ascii mode.
parent
9635e941
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
file.c
dlls/msvcrt/file.c
+2
-1
file.c
dlls/msvcrt/tests/file.c
+20
-10
No files found.
dlls/msvcrt/file.c
View file @
b4c1c67e
...
...
@@ -2550,8 +2550,9 @@ MSVCRT_size_t CDECL MSVCRT_fread(void *ptr, MSVCRT_size_t size, MSVCRT_size_t nm
}
pread
+=
i
;
rcnt
-=
i
;
ptr
=
(
char
*
)
ptr
+
i
;
/* expose feof condition in the flags
* MFC tests file->_flag for feof, and doesn't
not
call feof())
* MFC tests file->_flag for feof, and doesn't call feof())
*/
if
(
MSVCRT_fdesc
[
file
->
_file
].
wxflag
&
WX_ATEOF
)
file
->
_flag
|=
MSVCRT__IOEOF
;
...
...
dlls/msvcrt/tests/file.c
View file @
b4c1c67e
...
...
@@ -139,20 +139,20 @@ static void test_readmode( BOOL ascii_mode )
static
const
char
outbuffer
[]
=
"0,1,2,3,4,5,6,7,8,9
\r\n\r\n
A,B,C,D,E
\r\n
X,Y,Z"
;
static
const
char
padbuffer
[]
=
"ghjghjghjghj"
;
static
const
char
nlbuffer
[]
=
"
\r\n
"
;
char
buffer
[
MSVCRT_BUFSIZ
+
256
]
;
char
buffer
[
2
*
MSVCRT_BUFSIZ
+
256
],
*
optr
;
int
fd
;
FILE
*
file
;
int
i
,
j
,
fp
,
ao
,
*
ip
,
pl
;
int
i
,
j
,
m
,
fp
,
ao
,
*
ip
,
pl
;
long
l
;
fd
=
open
(
"fdopen.tst"
,
O_WRONLY
|
O_CREAT
|
O_BINARY
,
_S_IREAD
|
_S_IWRITE
);
/* an internal buffer of MSVCRT_BUFSIZ is maintained, so make a file big
* enough to test operations that cross the buffer boundary
*/
j
=
(
MSVCRT_BUFSIZ
-
4
)
/
strlen
(
padbuffer
);
j
=
(
2
*
MSVCRT_BUFSIZ
-
4
)
/
strlen
(
padbuffer
);
for
(
i
=
0
;
i
<
j
;
i
++
)
write
(
fd
,
padbuffer
,
strlen
(
padbuffer
));
j
=
(
MSVCRT_BUFSIZ
-
4
)
%
strlen
(
padbuffer
);
j
=
(
2
*
MSVCRT_BUFSIZ
-
4
)
%
strlen
(
padbuffer
);
for
(
i
=
0
;
i
<
j
;
i
++
)
write
(
fd
,
&
padbuffer
[
i
],
1
);
write
(
fd
,
nlbuffer
,
strlen
(
nlbuffer
));
...
...
@@ -173,9 +173,9 @@ static void test_readmode( BOOL ascii_mode )
/* first is a test of fgets, ftell, fseek */
ok
(
ftell
(
file
)
==
0
,
"Did not start at beginning of file in %s
\n
"
,
IOMODE
);
ok
(
fgets
(
buffer
,
MSVCRT_BUFSIZ
+
256
,
file
)
!=
0
,
"padding line fgets failed unexpected in %s
\n
"
,
IOMODE
);
ok
(
fgets
(
buffer
,
2
*
MSVCRT_BUFSIZ
+
256
,
file
)
!=
0
,
"padding line fgets failed unexpected in %s
\n
"
,
IOMODE
);
l
=
ftell
(
file
);
pl
=
MSVCRT_BUFSIZ
-
2
;
pl
=
2
*
MSVCRT_BUFSIZ
-
2
;
ok
(
l
==
pl
,
"padding line ftell got %ld should be %d in %s
\n
"
,
l
,
pl
,
IOMODE
);
ok
(
lstrlenA
(
buffer
)
==
pl
+
ao
,
"padding line fgets got size %d should be %d in %s
\n
"
,
lstrlenA
(
buffer
),
pl
+
ao
,
IOMODE
);
...
...
@@ -209,10 +209,20 @@ static void test_readmode( BOOL ascii_mode )
ok
(
ftell
(
file
)
==
0
,
"Did not start at beginning of file in %s
\n
"
,
IOMODE
);
ok
(
fgets
(
buffer
,
MSVCRT_BUFSIZ
-
6
,
file
)
!=
0
,
"padding line fgets failed unexpected in %s
\n
"
,
IOMODE
);
j
=
strlen
(
outbuffer
);
i
=
fread
(
buffer
,
1
,
256
,
file
);
ok
(
i
==
j
+
6
+
ao
*
4
,
"fread failed, expected %d got %d in %s
\n
"
,
j
+
6
+
ao
*
4
,
i
,
IOMODE
);
i
=
fread
(
buffer
,
1
,
MSVCRT_BUFSIZ
+
strlen
(
outbuffer
)
,
file
);
ok
(
i
==
MSVCRT_BUFSIZ
+
j
,
"fread failed, expected %d got %d in %s
\n
"
,
MSVCRT_BUFSIZ
+
j
,
i
,
IOMODE
);
l
=
ftell
(
file
);
ok
(
l
==
pl
+
j
+
1
,
"ftell after fread got %ld should be %d in %s
\n
"
,
l
,
pl
+
j
+
1
,
IOMODE
);
ok
(
l
==
pl
+
j
-
(
ao
*
4
)
-
5
,
"ftell after fread got %ld should be %d in %s
\n
"
,
l
,
pl
+
j
-
(
ao
*
4
)
-
5
,
IOMODE
);
for
(
m
=
0
;
m
<
3
;
m
++
)
ok
(
buffer
[
m
]
==
padbuffer
[
m
+
(
MSVCRT_BUFSIZ
-
4
)
%
strlen
(
padbuffer
)],
"expected %c got %c
\n
"
,
padbuffer
[
m
],
buffer
[
m
]);
m
+=
MSVCRT_BUFSIZ
+
2
+
ao
;
optr
=
(
char
*
)
outbuffer
;
for
(;
m
<
i
;
m
++
)
{
ok
(
buffer
[
m
]
==*
optr
,
"char %d expected %c got %c in %s
\n
"
,
m
,
*
optr
,
buffer
[
m
],
IOMODE
);
optr
++
;
if
(
ao
&&
(
*
optr
==
'\r'
))
optr
++
;
}
/* fread should return the requested number of bytes if available */
rewind
(
file
);
ok
(
ftell
(
file
)
==
0
,
"Did not start at beginning of file in %s
\n
"
,
IOMODE
);
...
...
@@ -235,7 +245,7 @@ static void test_readmode( BOOL ascii_mode )
/* test some additional functions */
rewind
(
file
);
ok
(
ftell
(
file
)
==
0
,
"Did not start at beginning of file in %s
\n
"
,
IOMODE
);
ok
(
fgets
(
buffer
,
MSVCRT_BUFSIZ
+
256
,
file
)
!=
0
,
"padding line fgets failed unexpected in %s
\n
"
,
IOMODE
);
ok
(
fgets
(
buffer
,
2
*
MSVCRT_BUFSIZ
+
256
,
file
)
!=
0
,
"padding line fgets failed unexpected in %s
\n
"
,
IOMODE
);
i
=
_getw
(
file
);
ip
=
(
int
*
)
outbuffer
;
ok
(
i
==
*
ip
,
"_getw failed, expected %08x got %08x in %s
\n
"
,
*
ip
,
i
,
IOMODE
);
...
...
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