File autofs-5-1-3-fix-unset-tsd-group-name-handling.patch of Package autofs
From: Ian Kent <raven@themaw.net>
Subject: autofs-5.1.3 - fix unset tsd group name handling
Patch-mainline: Submitted, http://www.spinics.net/lists/autofs/msg01725.html
References: bsc#1062482
Commit 1a64a6bbc5 changed set_tsd_user_vars() to set thread specific
values even if the group name could not be obtained.
But the structure holding the values was not initialized on allocation
so the group field might not be NULL when no group name is available.
Also the macro addition and removal functions didn't properly handle a
macro value of NULL.
Signed-off-by: Ian Kent <raven@themaw.net>
Reported-by: Donald Buczek <buczek@molgen.mpg.de>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
lib/macros.c | 8 +++++---
lib/mounts.c | 1 +
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/macros.c b/lib/macros.c
index ff9ba89..dfdca85 100644
--- a/lib/macros.c
+++ b/lib/macros.c
@@ -281,18 +281,20 @@ macro_addvar(struct substvar *table, const char *str, int len, const char *value
}
if (lv) {
- char *this = malloc(strlen(value) + 1);
+ const char *val = value ? value : "";
+ char *this = malloc(strlen(val) + 1);
if (!this) {
lv = table;
goto done;
}
- strcpy(this, value);
+ strcpy(this, val);
free(lv->val);
lv->val = this;
if (lv != table)
lv = table;
} else {
struct substvar *new;
+ const char *this = value ? value : "";
char *def, *val;
def = strdup(str);
@@ -302,7 +304,7 @@ macro_addvar(struct substvar *table, const char *str, int len, const char *value
}
def[len] = '\0';
- val = strdup(value);
+ val = strdup(this);
if (!val) {
lv = table;
free(def);
diff --git a/lib/mounts.c b/lib/mounts.c
index ce6a60a..0b38bd8 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -1463,6 +1463,7 @@ void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid)
error(logopt, "failed alloc tsv storage");
return;
}
+ memset(tsv, 0, sizeof(struct thread_stdenv_vars));
tsv->uid = uid;
tsv->gid = gid;