Blame SOURCES/autofs-5.1.3-fix-unset-tsd-group-name-handling.patch

304803
autofs-5.1.3 - fix unset tsd group name handling
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
Commit 1a64a6bbc5 changed set_tsd_user_vars() to the thread specific
304803
values even if the group name could not be obtained.
304803
304803
But the structure holding the values was not initialized on allocation
304803
so the group field might not be NULL when no group name is available.
304803
304803
Also the macro addition and removal functions didn't properly handle a
304803
macro value of NULL.
304803
304803
Signed-off-by: Ian Kent <raven@themaw.net>
304803
Reported-by: Donald Buczek <buczek@molgen.mpg.de>
304803
---
304803
 CHANGELOG    |    1 +
304803
 lib/macros.c |    8 +++++---
304803
 lib/mounts.c |    1 +
304803
 3 files changed, 7 insertions(+), 3 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -250,6 +250,7 @@
304803
 - increase worker thread per-thread stack size.
304803
 - limit getgrgid_r() buffer size.
304803
 - add congigure option for limiting getgrgid_r() stack usage.
304803
+- fix unset tsd group name handling.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/lib/macros.c
304803
+++ autofs-5.0.7/lib/macros.c
304803
@@ -281,18 +281,20 @@ macro_addvar(struct substvar *table, con
304803
 	}
304803
 
304803
 	if (lv) {
304803
-		char *this = malloc(strlen(value) + 1);
304803
+		const char *val = value ? value : "";
304803
+		char *this = malloc(strlen(val) + 1);
304803
 		if (!this) {
304803
 			lv = table;
304803
 			goto done;
304803
 		}
304803
-		strcpy(this, value);
304803
+		strcpy(this, val);
304803
 		free(lv->val);
304803
 		lv->val = this;
304803
 		if (lv != table)
304803
 			lv = table;
304803
 	} else {
304803
 		struct substvar *new;
304803
+		const char *this = value ? value : "";
304803
 		char *def, *val;
304803
 
304803
 		def = strdup(str);
304803
@@ -302,7 +304,7 @@ macro_addvar(struct substvar *table, con
304803
 		}
304803
 		def[len] = '\0';
304803
 
304803
-		val = strdup(value);
304803
+		val = strdup(this);
304803
 		if (!val) {
304803
 			lv = table;
304803
 			free(def);
304803
--- autofs-5.0.7.orig/lib/mounts.c
304803
+++ autofs-5.0.7/lib/mounts.c
304803
@@ -1456,6 +1456,7 @@ void set_tsd_user_vars(unsigned int logo
304803
 		error(logopt, "failed alloc tsv storage");
304803
 		return;
304803
 	}
304803
+	memset(tsv, 0, sizeof(struct thread_stdenv_vars));
304803
 
304803
 	tsv->uid = uid;
304803
 	tsv->gid = gid;