summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-06-16 15:36:08 -0400
committerNick Mathewson <nickm@torproject.org>2016-06-16 15:36:08 -0400
commit128ab31c649d3e9ecef284fa3f751dbea13682a6 (patch)
tree20be124c95618de39d37dda6ff199e4ba8264a73 /src/test/test_util.c
parentdd73787190ebe9821f8c3574fc1c08d54314699e (diff)
downloadtor-128ab31c649d3e9ecef284fa3f751dbea13682a6.tar.gz
tor-128ab31c649d3e9ecef284fa3f751dbea13682a6.zip
Mark code unreachable in unescape_string()
Also, add tests for it in case someday it does become reachable.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 55aff31046..c3d76c56d2 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1228,6 +1228,41 @@ test_util_config_line_escaped_content(void *arg)
tt_ptr_op(str,OP_EQ, NULL);
tor_free(k); tor_free(v);
+ /* more things to try. */
+ /* Bad hex: */
+ strlcpy(buf1, "Foo \"\\x9g\"\n", sizeof(buf1));
+ strlcpy(buf2, "Foo \"\\xg0\"\n", sizeof(buf2));
+ strlcpy(buf3, "Foo \"\\xf\"\n", sizeof(buf3));
+ /* bad escape */
+ strlcpy(buf4, "Foo \"\\q\"\n", sizeof(buf4));
+ /* missing endquote */
+ strlcpy(buf5, "Foo \"hello\n", sizeof(buf5));
+
+ str=buf1;
+ str = parse_config_line_from_str(str, &k, &v);
+ tt_ptr_op(str,OP_EQ, NULL);
+ tor_free(k); tor_free(v);
+
+ str=buf2;
+ str = parse_config_line_from_str(str, &k, &v);
+ tt_ptr_op(str,OP_EQ, NULL);
+ tor_free(k); tor_free(v);
+
+ str=buf3;
+ str = parse_config_line_from_str(str, &k, &v);
+ tt_ptr_op(str,OP_EQ, NULL);
+ tor_free(k); tor_free(v);
+
+ str=buf4;
+ str = parse_config_line_from_str(str, &k, &v);
+ tt_ptr_op(str,OP_EQ, NULL);
+ tor_free(k); tor_free(v);
+
+ str=buf5;
+ str = parse_config_line_from_str(str, &k, &v);
+ tt_ptr_op(str,OP_EQ, NULL);
+ tor_free(k); tor_free(v);
+
done:
tor_free(k);
tor_free(v);