chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
acd34fa
)
fileio: initialize errno to zero before we do fread()
author
Lennart Poettering
<lennart@poettering.net>
Fri, 22 Sep 2017 19:05:03 +0000
(21:05 +0200)
committer
Sven Eden
<yamakuzure@gmx.net>
Fri, 22 Sep 2017 19:05:03 +0000
(21:05 +0200)
if there was something in the read buffer already errno might not be set
on error, let's detect that case.
src/basic/fileio.c
patch
|
blob
|
history
diff --git
a/src/basic/fileio.c
b/src/basic/fileio.c
index 5dc303bb48eb028c213cadc67bfc2ef59a47d194..333effa5ffbefd6a4bb3b1965e21b8ae23fe01bd 100644
(file)
--- a/
src/basic/fileio.c
+++ b/
src/basic/fileio.c
@@
-287,12
+287,13
@@
int read_full_stream(FILE *f, char **contents, size_t *size) {
return -ENOMEM;
buf = t;
+ errno = 0;
k = fread(buf + l, 1, n - l, f);
if (k > 0)
l += k;
if (ferror(f))
- return
-errno
;
+ return
errno > 0 ? -errno : -EIO
;
if (feof(f))
break;