summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2008-05-28 21:44:32 +0000
committerstefanf <stefanf@FreeBSD.org>2008-05-28 21:44:32 +0000
commit20001eb2e24e4ed036e6fc8a56b3d644856de4eb (patch)
tree619311d0472d9232c1ad0e7640c990b698882d11 /bin
parentd488b8018a2d5f6ef2196c4290740c6e47216f63 (diff)
downloadFreeBSD-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.c7
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;
OpenPOWER on IntegriCloud