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

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