|
Kamil Dudka |
724b3e |
From 3427fe59c2d76ddbf4b23908c6ae5272734c7c8b Mon Sep 17 00:00:00 2001
|
|
Kamil Dudka |
724b3e |
From: "Barton E. Schaefer" <schaefer@zsh.org>
|
|
Kamil Dudka |
724b3e |
Date: Wed, 20 May 2015 10:14:04 -0700
|
|
Kamil Dudka |
724b3e |
Subject: [PATCH] 35231: make mkevnstr() safe for NULL value
|
|
Kamil Dudka |
724b3e |
|
|
Kamil Dudka |
724b3e |
Upstream-commit: af957f2ed6287f66953742fbca69188cecb98fbf
|
|
Kamil Dudka |
724b3e |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
Kamil Dudka |
724b3e |
---
|
|
Kamil Dudka |
724b3e |
Src/params.c | 14 +++++++++-----
|
|
Kamil Dudka |
724b3e |
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
Kamil Dudka |
724b3e |
|
|
Kamil Dudka |
724b3e |
diff --git a/Src/params.c b/Src/params.c
|
|
Kamil Dudka |
724b3e |
index 61edc5d..d0ce0a9 100644
|
|
Kamil Dudka |
724b3e |
--- a/Src/params.c
|
|
Kamil Dudka |
724b3e |
+++ b/Src/params.c
|
|
Kamil Dudka |
724b3e |
@@ -4534,17 +4534,21 @@ addenv(Param pm, char *value)
|
|
Kamil Dudka |
724b3e |
static char *
|
|
Kamil Dudka |
724b3e |
mkenvstr(char *name, char *value, int flags)
|
|
Kamil Dudka |
724b3e |
{
|
|
Kamil Dudka |
724b3e |
- char *str, *s;
|
|
Kamil Dudka |
724b3e |
- int len_name, len_value;
|
|
Kamil Dudka |
724b3e |
+ char *str, *s = value;
|
|
Kamil Dudka |
724b3e |
+ int len_name, len_value = 0;
|
|
Kamil Dudka |
724b3e |
|
|
Kamil Dudka |
724b3e |
len_name = strlen(name);
|
|
Kamil Dudka |
724b3e |
- for (len_value = 0, s = value;
|
|
Kamil Dudka |
724b3e |
- *s && (*s++ != Meta || *s++ != 32); len_value++);
|
|
Kamil Dudka |
724b3e |
+ if (s)
|
|
Kamil Dudka |
724b3e |
+ while (*s && (*s++ != Meta || *s++ != 32))
|
|
Kamil Dudka |
724b3e |
+ len_value++;
|
|
Kamil Dudka |
724b3e |
s = str = (char *) zalloc(len_name + len_value + 2);
|
|
Kamil Dudka |
724b3e |
strcpy(s, name);
|
|
Kamil Dudka |
724b3e |
s += len_name;
|
|
Kamil Dudka |
724b3e |
*s = '=';
|
|
Kamil Dudka |
724b3e |
- copyenvstr(s, value, flags);
|
|
Kamil Dudka |
724b3e |
+ if (value)
|
|
Kamil Dudka |
724b3e |
+ copyenvstr(s, value, flags);
|
|
Kamil Dudka |
724b3e |
+ else
|
|
Kamil Dudka |
724b3e |
+ *++s = '\0';
|
|
Kamil Dudka |
724b3e |
return str;
|
|
Kamil Dudka |
724b3e |
}
|
|
Kamil Dudka |
724b3e |
|
|
Kamil Dudka |
724b3e |
--
|
|
Kamil Dudka |
724b3e |
2.4.1
|
|
Kamil Dudka |
724b3e |
|