diff options
author | thomas <thomas@FreeBSD.org> | 2003-02-10 11:20:58 +0000 |
---|---|---|
committer | thomas <thomas@FreeBSD.org> | 2003-02-10 11:20:58 +0000 |
commit | 8638b961ca051972aa17ca0fd476f16998b984a0 (patch) | |
tree | 6eaf7787c0804164bcd7066c74914a16a4dbcca5 /usr.sbin/cron/lib/env.c | |
parent | 6a79467bbde44ba077bc5179639dd9dc5565c929 (diff) | |
download | FreeBSD-src-8638b961ca051972aa17ca0fd476f16998b984a0.zip FreeBSD-src-8638b961ca051972aa17ca0fd476f16998b984a0.tar.gz |
Allow inner whitespace in the right-hand side of an environment variable
assignment even if it is not quoted (as advertised by the man page).
This fixes a regression wrt RELENG_4 introduced in rev. 1.11.
Problem noted and patch tested by: CHOI Junho <cjh@kr.FreeBSD.org>
Reviewed by: roberto
Diffstat (limited to 'usr.sbin/cron/lib/env.c')
-rw-r--r-- | usr.sbin/cron/lib/env.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/usr.sbin/cron/lib/env.c b/usr.sbin/cron/lib/env.c index c2adb49..fd35817 100644 --- a/usr.sbin/cron/lib/env.c +++ b/usr.sbin/cron/lib/env.c @@ -193,14 +193,16 @@ load_env(envstr, f) break; } } else { - if (isspace (*c)) { - state++; - c++; - break; - } - if (state == NAME && *c == '=') { - state++; - break; + if (state == NAME) { + if (isspace (*c)) { + c++; + state++; + break; + } + if (*c == '=') { + state++; + break; + } } } *str++ = *c++; @@ -232,9 +234,14 @@ load_env(envstr, f) Set_LineNum(fileline); return (FALSE); } + if (state == VALUE) { + /* End of unquoted value: trim trailing whitespace */ + c = val + strlen (val); + while (c > val && isspace (*(c - 1))) + *(--c) = '\0'; + } - /* 2 fields from parser; looks like an env setting - */ + /* 2 fields from parser; looks like an env setting */ if (strlen(name) + 1 + strlen(val) >= MAX_ENVSTR-1) return (FALSE); |