Blame SOURCES/autofs-5.1.0-check-options-length-before-use-in-parse_amd_c.patch

304803
autofs-5.1.0 - check options length before use in parse_amd.c
304803
304803
From: Ian Kent <ikent@redhat.com>
304803
304803
Check for temporary buffer overflow before copy at several places in
304803
modules/parse_amd.c.
304803
---
304803
 CHANGELOG           |    1 +
304803
 modules/parse_amd.c |   36 ++++++++++++++++++++++++++++++++----
304803
 2 files changed, 33 insertions(+), 4 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -141,6 +141,7 @@
304803
 - check amd lex buffer len before copy.
304803
 - add return check in ldap check_map_indirect().
304803
 - check host macro is set before use.
304803
+- check options length before use in parse_amd.c.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/modules/parse_amd.c
304803
+++ autofs-5.0.7/modules/parse_amd.c
304803
@@ -906,9 +906,20 @@ static int do_auto_mount(struct autofs_p
304803
 {
304803
 	char target[PATH_MAX + 1];
304803
 
304803
-	if (!entry->map_type)
304803
+	if (!entry->map_type) {
304803
+		if (strlen(entry->fs) > PATH_MAX) {
304803
+			error(ap->logopt, MODPREFIX
304803
+			     "error: fs option length is too long");
304803
+			return 0;
304803
+		}
304803
 		strcpy(target, entry->fs);
304803
-	else {
304803
+	} else {
304803
+		if (strlen(entry->fs) +
304803
+		    strlen(entry->map_type) + 5 > PATH_MAX) {
304803
+			error(ap->logopt, MODPREFIX
304803
+			     "error: fs + maptype options length is too long");
304803
+			return 0;
304803
+		}
304803
 		strcpy(target, entry->map_type);
304803
 		strcat(target, ",amd:");
304803
 		strcat(target, entry->fs);
304803
@@ -925,10 +936,21 @@ static int do_link_mount(struct autofs_p
304803
 	const char *opts = (entry->opts && *entry->opts) ? entry->opts : NULL;
304803
 	int ret;
304803
 
304803
-	if (entry->sublink)
304803
+	if (entry->sublink) {
304803
+		if (strlen(entry->sublink) > PATH_MAX) {
304803
+			error(ap->logopt, MODPREFIX
304803
+			     "error: sublink option length is too long");
304803
+			return 0;
304803
+		}
304803
 		strcpy(target, entry->sublink);
304803
-	else
304803
+	} else {
304803
+		if (strlen(entry->fs) > PATH_MAX) {
304803
+			error(ap->logopt, MODPREFIX
304803
+			     "error: fs option length is too long");
304803
+			return 0;
304803
+		}
304803
 		strcpy(target, entry->fs);
304803
+	}
304803
 
304803
 	if (!(flags & CONF_AUTOFS_USE_LOFS))
304803
 		goto symlink;
304803
@@ -1017,6 +1039,12 @@ static int do_nfs_mount(struct autofs_po
304803
 	unsigned int umount = 0;
304803
 	int ret = 0;
304803
 
304803
+	if (strlen(entry->rhost) + strlen(entry->rfs) + 1 > PATH_MAX) {
304803
+		error(ap->logopt, MODPREFIX
304803
+		     "error: rhost + rfs options length is too long");
304803
+		return 0;
304803
+	}
304803
+
304803
 	strcpy(target, entry->rhost);
304803
 	strcat(target, ":");
304803
 	strcat(target, entry->rfs);