autofs-5.1.0 - fix config entry read buffer not checked
From: Ian Kent <raven@themaw.net>
Check the length of config file line read in and report truncation
if it was too long.
---
CHANGELOG | 1 +
lib/defaults.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index bc8b9d1..21c3ecd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
- fix incorrect round robin host detection.
- fix race accessing qdn in get_query_dn().
- fix leak in cache_push_mapent().
+- fix config entry read buffer not checked.
04/06/2014 autofs-5.1.0
=======================
diff --git a/lib/defaults.c b/lib/defaults.c
index d29a976..a83dcee 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -835,7 +835,7 @@ static int parse_line(char *line, char **sec, char **res, char **value)
static int read_config(unsigned int to_syslog, FILE *f, const char *name)
{
- char buf[MAX_LINE_LEN];
+ char buf[MAX_LINE_LEN + 2];
char secbuf[MAX_SECTION_NAME];
char *new_sec;
char *res;
@@ -843,6 +843,12 @@ static int read_config(unsigned int to_syslog, FILE *f, const char *name)
new_sec = NULL;
while ((res = fgets(buf, MAX_LINE_LEN, f))) {
char *sec, *key, *value;
+
+ if (strlen(res) > MAX_LINE_LEN) {
+ message(to_syslog, "%s was truncated, ignored", res);
+ continue;
+ }
+
sec = key = value = NULL;
if (!parse_line(res, &sec, &key, &value))
continue;