[hackers] [sbase] Fix segmentation fault in tr(1) || FRIGN
commit ac29778bdc15849f4b959969b9ca780e68e48fa7
Author: FRIGN <dev_AT_frign.de>
Date: Sat Jan 24 23:00:34 2015 +0100
Fix segmentation fault in tr(1)
and make the parser stricter.
diff --git a/tr.c b/tr.c
index e2e6b71..7aa71e7 100644
--- a/tr.c
+++ b/tr.c
_AT_@ -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;
_AT_@ -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;
Received on Sat Jan 24 2015 - 23:44:59 CET
This archive was generated by hypermail 2.3.0
: Sat Jan 24 2015 - 23:48:14 CET