[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CTLESC and CTLNUL not dequoted in exported function definitions
From: |
Grisha Levit |
Subject: |
CTLESC and CTLNUL not dequoted in exported function definitions |
Date: |
Sun, 9 Apr 2017 00:16:00 -0400 |
For example:
$ f() { $'\001'; }; export -f f; printenv BASH_FUNC_f%% | xxd
00000000: 2829 207b 2020 2701 0127 0a7d 0a () { '..'.}.
I think the following should fix it:
diff --git a/variables.c b/variables.c
index 87203dac..acac867e 100644
--- a/variables.c
+++ b/variables.c
@@ -4309,7 +4309,7 @@ mk_env_string (name, value, isfunc)
int isfunc;
{
size_t name_len, value_len;
- char *p, *q;
+ char *p, *q, *t;
name_len = strlen (name);
value_len = STRLEN (value);
@@ -4336,7 +4336,17 @@ mk_env_string (name, value, isfunc)
q[0] = '=';
if (value && *value)
- memcpy (q + 1, value, value_len + 1);
+ if (isfunc)
+ {
+ t = (char *)xmalloc (value_len + 1);
+ strcpy (t, value);
+ remove_quoted_escapes (t);
+ value_len = STRLEN(t);
+ memcpy (q + 1, t, value_len + 1);
+ free (t);
+ }
+ else
+ memcpy (q + 1, value, value_len + 1);
else
q[1] = '\0';
- CTLESC and CTLNUL not dequoted in exported function definitions,
Grisha Levit <=