[tor-commits] [tor/master] Provide large enough buffer in test_util_sscanf()

nickm at torproject.org nickm at torproject.org
Tue Mar 27 14:00:08 UTC 2012


commit 582f747049ae9595380fe06df8e6b26c735b50c1
Author: Sebastian Hahn <sebastian at torproject.org>
Date:   Tue Mar 27 14:04:15 2012 +0200

    Provide large enough buffer in test_util_sscanf()
    
    This was causing crashes during unit test runs, as stack smashing
    protections got triggered. Issue spotted by weasel
---
 changes/bug5449      |    6 ++++++
 src/test/test_util.c |    2 +-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/changes/bug5449 b/changes/bug5449
new file mode 100644
index 0000000..48babb3
--- /dev/null
+++ b/changes/bug5449
@@ -0,0 +1,6 @@
+  o Minor bugfixes:
+    - In the testsuite, provide a large enough buffer in the tor_sscanf
+      unit test. We'd otherwise overrun that buffer and crash during the
+      unit tests. Fixes bug 5449; bugfix on 0.2.3.12-alpha. Thanks weasel
+      for spotting the bug.
+
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 0187187..9da4cb7 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1376,7 +1376,7 @@ static void
 test_util_sscanf(void)
 {
   unsigned u1, u2, u3;
-  char s1[10], s2[10], s3[10], ch;
+  char s1[20], s2[10], s3[10], ch;
   int r;
 
   /* Simple tests (malformed patterns, literal matching, ...) */



More information about the tor-commits mailing list