commit f9ad35c361b4c183a55dec3f9fa7eb728e089730 Author: Esteban Manchado Velázquez emanchado@demiurgo.org Date: Fri Feb 3 23:28:40 2012 +0100
Add test for broken hex parsing
* The test currently fails, but it's commented out (with an "#if 0") * As a broken octal actually gives a parse error, it seems fair that this fails, too --- src/test/test_util.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/test/test_util.c b/src/test/test_util.c index b8c0544..4bcd49f 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -304,6 +304,7 @@ test_util_config_line_escaped_content(void) char buf2[128]; char buf3[128]; char buf4[128]; + char buf5[128]; char *k=NULL, *v=NULL; const char *str;
@@ -330,6 +331,9 @@ test_util_config_line_escaped_content(void) strlcpy(buf4, "BrokenOctal "\8"\n" , sizeof(buf4));
+ strlcpy(buf5, "BrokenHex "\xg4"\n" + , sizeof(buf5)); + str = buf1;
str = parse_config_line_from_str(str, &k, &v); @@ -405,6 +409,14 @@ test_util_config_line_escaped_content(void) test_eq_ptr(str, NULL); tor_free(k); tor_free(v);
+#if 0 + str = buf5; + + str = parse_config_line_from_str(str, &k, &v); + test_eq_ptr(str, NULL); + tor_free(k); tor_free(v); +#endif + done: tor_free(k); tor_free(v);