summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-14 12:56:12 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-14 12:56:12 +0100
commit31fd02f00977720c20c9cdd74342697b593dee9b (patch)
treea683bf56ff7d175fe65535a3b53d3f9fc543edb8
parent58d9d89b4b41189bdcea86c2ad5cf708b7d54aca (diff)
downloadsystemd-31fd02f00977720c20c9cdd74342697b593dee9b.tar.gz
systemd-31fd02f00977720c20c9cdd74342697b593dee9b.tar.bz2
systemd-31fd02f00977720c20c9cdd74342697b593dee9b.zip
fileio: fail early if we can't return the number of bytes we read anymore in an int
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.
-rw-r--r--src/basic/fileio.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 83f1f508dd..d434cb4d2c 100644
--- 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) {