[systemd-devel] [PATCH] fileio: also escape $ and ` when writing out env vars

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Tue Apr 16 21:41:53 PDT 2013


On Sun, Apr 14, 2013 at 02:54:09PM +0300, Mantas Mikulėnas wrote:
> These are also considered special by sh and bash.
> ---
>  src/shared/fileio.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/shared/fileio.c b/src/shared/fileio.c
> index 400a416..617afea 100644
> --- a/src/shared/fileio.c
> +++ b/src/shared/fileio.c
> @@ -529,11 +529,11 @@ static void write_env_var(FILE *f, const char *v) {
>          p++;
>          fwrite(v, 1, p-v, f);
>  
> -        if (string_has_cc(p) || chars_intersect(p, WHITESPACE "\'\"\\")) {
> +        if (string_has_cc(p) || chars_intersect(p, WHITESPACE "\'\"\\`$")) {
>                  fputc('\"', f);
>  
>                  for (; *p; p++) {
> -                        if (strchr("\'\"\\", *p))
> +                        if (strchr("\'\"\\`$", *p))
>                                  fputc('\\', f);
>  
>                          fputc(*p, f);
Applied.

Zbyszek


More information about the systemd-devel mailing list