sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit ee843a2e092059eca06c5ce5202c30fffa1b3a8f
parent c369844ae248279b3c2e2edec568311e476ccfb2
Author: FRIGN <dev@frign.de>
Date:   Sat, 24 Jan 2015 23:00:34 +0100

Fix segmentation fault in tr(1)

and make the parser stricter.

Diffstat:
Mtr.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tr.c b/tr.c @@ -75,7 +75,7 @@ resolveescapes(Rune *r, size_t len) { size_t i, off, m, factor, q; - for (i = 0; i < len - 1; i++) { + for (i = 0; i < len; i++) { if (r[i] != '\\') continue; off = 0; @@ -97,7 +97,7 @@ resolveescapes(Rune *r, size_t len) if (r[m] < '0' || r[m] > '7') break; if (m == i + 1) - continue; + eprintf("tr: invalid escape sequence '\\%c'\n", r[i + 1]); off += m - i - 1; for (--m, q = 0, factor = 1; m > i; m--) { q += (r[m] - '0') * factor;