summaryrefslogtreecommitdiff
path: root/bin/ksh/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ksh/eval.c')
-rw-r--r--bin/ksh/eval.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index 49b4fdd5309..2c5b5429b8b 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.54 2017/08/27 00:29:04 nayden Exp $ */
+/* $OpenBSD: eval.c,v 1.55 2018/01/01 19:45:56 millert Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -1114,10 +1114,11 @@ debunk(char *dp, const char *sp, size_t dlen)
char *d, *s;
if ((s = strchr(sp, MAGIC))) {
- if (s - sp >= dlen)
+ size_t slen = s - sp;
+ if (slen >= dlen)
return dp;
- memcpy(dp, sp, s - sp);
- for (d = dp + (s - sp); *s && (d - dp < dlen); s++)
+ memcpy(dp, sp, slen);
+ for (d = dp + slen; *s && (d < dp + dlen); s++)
if (!ISMAGIC(*s) || !(*++s & 0x80) ||
!strchr("*+?@! ", *s & 0x7f))
*d++ = *s;
@@ -1125,7 +1126,7 @@ debunk(char *dp, const char *sp, size_t dlen)
/* extended pattern operators: *+?@! */
if ((*s & 0x7f) != ' ')
*d++ = *s & 0x7f;
- if (d - dp < dlen)
+ if (d < dp + dlen)
*d++ = '(';
}
*d = '\0';