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:
2322326
)
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 7638ae87a8f5bd72801a8d203a797922245b5e8e..f4ab6612b36b7f2c796b6613ebdb4cbb2456948d 100644
(file)
--- a/
src/basic/fileio.c
+++ b/
src/basic/fileio.c
@@
-271,12
+271,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;