summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-03-03 18:02:36 +0000
committerNick Mathewson <nickm@torproject.org>2009-03-03 18:02:36 +0000
commitcbbc0c9c8615d4541d99a0e3ff2027b878893888 (patch)
tree2e0ed8a31c2793cba8d1eeb6813e77610d5670d1 /src/or/test.c
parent26d83fc04c66d2c592ff64b62830c171266b4f75 (diff)
downloadtor-cbbc0c9c8615d4541d99a0e3ff2027b878893888.tar.gz
tor-cbbc0c9c8615d4541d99a0e3ff2027b878893888.zip
Actually use tor_sscanf() to parse untrusted input.
svn:r18761
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 46f717e893..ff05b1dafb 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -2796,6 +2796,11 @@ test_util_sscanf(void)
test_eq(u1, 12u);
test_eq(u2, 3u);
test_eq(u3, 99u);
+
+ r = tor_sscanf("99% fresh", "%3u%% fresh", &u1); /* percents are scannable.*/
+ test_eq(r, 1);
+ test_eq(u1, 99);
+
r = tor_sscanf("hello", "%s", s1); /* %s needs a number. */
test_eq(r, -1);