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

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