projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
58d9d89
)
fileio: fail early if we can't return the number of bytes we read anymore in an int
author
Lennart Poettering
<lennart@poettering.net>
Fri, 14 Dec 2018 11:56:12 +0000
(12:56 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 14 Dec 2018 11:56:12 +0000
(12:56 +0100)
This is mostly paranoia, but let's better be safer than sorry. This of
course means there's always an implicit limit to how much we can read at
a time of 2G. But that should be ample.
src/basic/fileio.c
patch
|
blob
|
history
diff --git
a/src/basic/fileio.c
b/src/basic/fileio.c
index
83f1f50
..
d434cb4
100644
(file)
--- a/
src/basic/fileio.c
+++ b/
src/basic/fileio.c
@@
-762,6
+762,9
@@
int read_line(FILE *f, size_t limit, char **ret) {
if (n >= limit)
return -ENOBUFS;
+ if (count >= INT_MAX) /* We couldn't return the counter anymore as "int", hence refuse this */
+ return -ENOBUFS;
+
errno = 0;
c = fgetc_unlocked(f);
if (c == EOF) {