]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
rust/protover: fix null deref in protover_all_supported()
authorcypherpunks <cypherpunks@torproject.org>
Fri, 21 Sep 2018 04:57:26 +0000 (04:57 +0000)
committercypherpunks <cypherpunks@torproject.org>
Fri, 21 Sep 2018 04:57:26 +0000 (04:57 +0000)
Fortunately with the current callers it couldn't happen in practice.

Fix on d1820c1516a31a149fc51a9e5126bf899e4c4e08.

changes/bug27804 [new file with mode: 0644]
src/rust/protover/ffi.rs
src/test/test_protover.c

diff --git a/changes/bug27804 b/changes/bug27804
new file mode 100644 (file)
index 0000000..fa7fec0
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (rust):
+    - Fix a potential null dereference in protover_all_supported().
+      Add a test for it. Fixes bug 27804; bugfix on 0.3.3.1-alpha.
index 9656e8c31854a77dd487fbe76f68787ff82e98c8..ca9a504fe1594ec2fcc32d2f0817f70bf63f5e1d 100644 (file)
@@ -68,6 +68,9 @@ pub extern "C" fn protover_all_supported(
 
     if maybe_unsupported.is_some() {
         let unsupported: UnvalidatedProtoEntry = maybe_unsupported.unwrap();
+        if missing_out.is_null() {
+            return 0;
+        }
         let c_unsupported: CString = match CString::new(unsupported.to_string()) {
             Ok(n) => n,
             Err(_) => return 1,
index fb374c728beeeacf08700a6c4c1114efac05ec46..d1fc7752dd9f574ee05dbe96365ae6ab6d60be40 100644 (file)
@@ -259,6 +259,7 @@ test_protover_all_supported(void *arg)
   tt_ptr_op(msg, OP_EQ, NULL);
 
   // Some things we don't support
+  tt_assert(! protover_all_supported("Wombat=9", NULL));
   tt_assert(! protover_all_supported("Wombat=9", &msg));
   tt_str_op(msg, OP_EQ, "Wombat=9");
   tor_free(msg);