diff options
author | stefanf <stefanf@FreeBSD.org> | 2008-05-28 21:44:32 +0000 |
---|---|---|
committer | stefanf <stefanf@FreeBSD.org> | 2008-05-28 21:44:32 +0000 |
commit | 20001eb2e24e4ed036e6fc8a56b3d644856de4eb (patch) | |
tree | 619311d0472d9232c1ad0e7640c990b698882d11 /bin | |
parent | d488b8018a2d5f6ef2196c4290740c6e47216f63 (diff) | |
download | FreeBSD-src-20001eb2e24e4ed036e6fc8a56b3d644856de4eb.zip FreeBSD-src-20001eb2e24e4ed036e6fc8a56b3d644856de4eb.tar.gz |
Fix checking if a variable name is LINENO. As STPUTC changes the pointer if it
needs to enlarge the buffer, we must not keep a pointer to the beginning.
PR: ports/123879
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/parser.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 75b4cac..86f50fc 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1188,6 +1188,7 @@ parsesub: { int bracketed_name = 0; /* used to handle ${[0-9]*} variables */ int i; int linno; + int length; c = pgetc(); if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && @@ -1220,12 +1221,14 @@ parsesub: { subtype = 0; } if (!is_eof(c) && is_name(c)) { - p = out; + length = 0; do { STPUTC(c, out); c = pgetc(); + length++; } while (!is_eof(c) && is_in_name(c)); - if (out - p == 6 && strncmp(p, "LINENO", 6) == 0) { + if (length == 6 && + strncmp(out - length, "LINENO", length) == 0) { /* Replace the variable name with the * current line number. */ linno = plinno; |