sbase

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

commit fa0e5d6378ca0619a76d3098ce21bb4c631e43ee
parent 72b49a065b8423bf4148404a56ebbe202cb064c0
Author: Michael Forney <mforney@mforney.org>
Date:   Tue Mar  7 23:10:48 -0800

libutil/unescape: NULL terminate unescaped string

In commit 30fd43d7f3b8716054eb9867c835aadc423f652c, unescape was
simplified significantly, but the new version failed to NULL terminate
the resulting string.

This causes bad behavior in various utilities, for example tr:

Broken:

  $ echo b2 | tr '\142' '\143'
  c3

Fixed:

  $ echo b2 | tr '\142' '\143'
  c2

This bug breaks libtool's usage of tr, causing gcc to fail to build with
sbase.

Diffstat:
libutil/unescape.c | 1+
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/libutil/unescape.c b/libutil/unescape.c @@ -52,6 +52,7 @@ unescape(char *s) eprintf("invalid escape sequence '\\%c'\n", *r); } } + *w = '\0'; return w - s; }