autofs-5.1.2 - Fix size arg of fgets(3) From: Tomohiro Kusumi Since fgets(3) reads at most 1 less than size arg, it should probably pass MAX_LINE_LEN+1 given that the conditional in the next line tests if strlen() exceeds MAX_LINE_LEN. (i.e. MAX_LINE_LEN isn't designed to include terminating \0) buf has MAX_LINE_LEN+2 bytes, so passing MAX_LINE_LEN+1 is ok. Signed-off-by: Tomohiro Kusumi Signed-off-by: Ian Kent --- CHANGELOG | 1 + lib/defaults.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 99dc245..cb895c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ xx/xx/2016 autofs-5.1.3 - build: check for clock_gettime in librt. - fix compiler warning in try_remount(). - drop redundant \n in logerr(). +- Fix size arg of fgets(3). 15/06/2016 autofs-5.1.2 ======================= diff --git a/lib/defaults.c b/lib/defaults.c index 0e48a78..ae76513 100644 --- a/lib/defaults.c +++ b/lib/defaults.c @@ -879,7 +879,7 @@ static int read_config(unsigned int to_syslog, FILE *f, const char *name) char *res; new_sec = NULL; - while ((res = fgets(buf, MAX_LINE_LEN, f))) { + while ((res = fgets(buf, MAX_LINE_LEN + 1, f))) { char *sec, *key, *value; if (strlen(res) > MAX_LINE_LEN) {