[hackers] [sbase] libutil/unescape: NULL terminate unescaped string || Michael Forney
commit fa0e5d6378ca0619a76d3098ce21bb4c631e43ee
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Tue Mar 7 23:10:48 2017 -0800
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Fri Mar 24 10:40:32 2017 +0100
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.
diff --git a/libutil/unescape.c b/libutil/unescape.c
index 7523db3..d8ed2a2 100644
--- a/libutil/unescape.c
+++ b/libutil/unescape.c
_AT_@ -52,6 +52,7 @@ unescape(char *s)
eprintf("invalid escape sequence '\\%c'\n", *r);
}
}
+ *w = '\0';
return w - s;
}
Received on Fri Mar 24 2017 - 10:40:55 CET
This archive was generated by hypermail 2.3.0
: Fri Mar 24 2017 - 10:48:22 CET