[hackers] [sbase][PATCH] libutil/unescape.c: ensure \0 termination if short

From: Antoine Kaufmann <antoinek_AT_cs.washington.edu>
Date: Thu, 23 Mar 2017 11:29:15 -0700

30fd43d caused '\n' to turn into '<LF>n'. For me this broke tr '\n' ' '. The
underlying problem is that unescape is no longer writing a terminating \0 byte
if the unescaped string is shorter.

Signed-off-by: Antoine Kaufmann <antoinek_AT_cs.washington.edu>
---
 libutil/unescape.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/libutil/unescape.c b/libutil/unescape.c
index 7523db3..b25e200 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;
 }
-- 
2.11.0
Received on Thu Mar 23 2017 - 19:29:15 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 23 2017 - 19:36:16 CET