From: Denis Vlasenko Date: Sat, 26 Jul 2008 19:34:00 +0000 (-0000) Subject: tr: fix "access past the end of a string" bug 4354 X-Git-Tag: 1_12_0~91 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5e40070d38cf02b96da72db5c6612e8971ef65f0;p=oweals%2Fbusybox.git tr: fix "access past the end of a string" bug 4354 --- diff --git a/coreutils/tr.c b/coreutils/tr.c index e439fcb5b..28798fe4f 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c @@ -138,7 +138,7 @@ static unsigned int expand(const char *arg, char *buffer) arg += 3; /* skip CHAR=] */ continue; } - if (*arg != '-') { /* not [x-...] - copy verbatim */ + if (i == '\0' || *arg != '-') { /* not [x-...] - copy verbatim */ *buffer++ = '['; arg--; /* points to x */ continue; /* copy all, including eventual ']' */