Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Limkilde Svendsen
relibc
Commits
540395c0
Verified
Commit
540395c0
authored
6 years ago
by
Tom Almeida
Browse files
Options
Downloads
Patches
Plain Diff
Fix _IONBF crashing when reading
parent
a1ebe321
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/stdio/src/lib.rs
+13
-4
13 additions, 4 deletions
src/stdio/src/lib.rs
with
13 additions
and
4 deletions
src/stdio/src/lib.rs
+
13
−
4
View file @
540395c0
...
...
@@ -74,7 +74,11 @@ impl FILE {
self
.flags
|
=
constants
::
F_ERR
;
return
false
;
}
self
.read
=
Some
((
self
.buf
.len
()
-
1
,
self
.buf
.len
()
-
1
));
self
.read
=
if
self
.buf
.len
()
==
0
{
Some
((
0
,
0
))
}
else
{
Some
((
self
.buf
.len
()
-
1
,
self
.buf
.len
()
-
1
))
};
if
self
.flags
&
constants
::
F_EOF
>
0
{
false
}
else
{
...
...
@@ -343,7 +347,7 @@ pub extern "C" fn fgetpos(stream: &mut FILE, pos: Option<&mut fpos_t>) -> c_int
pub
extern
"C"
fn
fgets
(
s
:
*
mut
c_char
,
n
:
c_int
,
stream
:
&
mut
FILE
)
->
*
mut
c_char
{
use
core
::
slice
;
flockfile
(
stream
);
let
st
=
unsafe
{
slice
::
from_raw_parts_mut
(
s
,
n
as
usize
)
};
let
st
=
unsafe
{
slice
::
from_raw_parts_mut
(
s
as
*
mut
u8
,
n
as
usize
)
};
let
mut
len
=
n
;
...
...
@@ -372,14 +376,18 @@ pub extern "C" fn fgets(s: *mut c_char, n: c_int, stream: &mut FILE) -> *mut c_c
let
mut
idiff
=
0usize
;
for
_
in
(
0
..
(
len
-
1
)
as
usize
)
.take_while
(|
x
|
rpos
+
x
<
rend
)
{
let
pos
=
(
n
-
len
)
as
usize
;
st
[
pos
]
=
stream
.buf
[
rpos
+
idiff
]
as
i8
;
st
[
pos
]
=
stream
.buf
[
rpos
+
idiff
];
idiff
+=
1
;
len
-=
1
;
if
st
[
pos
]
==
b'\n'
as
i8
||
st
[
pos
]
==
stream
.buf_char
{
if
st
[
pos
]
==
b'\n'
||
st
[
pos
]
as
i8
==
stream
.buf_char
{
break
'outer
;
}
}
stream
.read
=
Some
((
rpos
+
idiff
,
rend
));
if
rend
-
rpos
==
0
{
len
-=
stream
.read
(
&
mut
st
[(
len
as
usize
)
..
])
as
i32
;
break
;
}
if
len
<=
1
{
break
;
}
...
...
@@ -856,6 +864,7 @@ pub extern "C" fn setvbuf(stream: &mut FILE, buf: *mut c_char, mode: c_int, size
if
mode
!=
_IONBF
{
vec!
[
0u8
;
1
]
}
else
{
stream
.unget
=
0
;
if
let
Some
(
_
)
=
stream
.write
{
stream
.write
=
Some
((
0
,
0
,
0
));
}
else
if
let
Some
(
_
)
=
stream
.read
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment