diff options
author | teor <teor@riseup.net> | 2020-05-18 21:50:35 +1000 |
---|---|---|
committer | teor <teor@riseup.net> | 2020-05-18 21:50:35 +1000 |
commit | 3efe53562fea2f4d71f0f620e10f4b5319b99fcb (patch) | |
tree | faf461869a846af4204423f09ed4b0f063cf0058 /src/rust | |
parent | f05c144d7c91df365c667a48c0d99f548d766437 (diff) | |
download | tor-3efe53562fea2f4d71f0f620e10f4b5319b99fcb.tar.gz tor-3efe53562fea2f4d71f0f620e10f4b5319b99fcb.zip |
rust/protover: Fix protocol version support error handling
Make Rust protocol version support checks consistent with the
undocumented error behaviour of the corresponding C code.
Fixes bug 34251; bugfix on 0.3.3.5-rc.
Diffstat (limited to 'src/rust')
-rw-r--r-- | src/rust/protover/ffi.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs index 14170d0353..2bf8d3a987 100644 --- a/src/rust/protover/ffi.rs +++ b/src/rust/protover/ffi.rs @@ -84,7 +84,7 @@ pub extern "C" fn protocol_list_supports_protocol( version: uint32_t, ) -> c_int { if c_protocol_list.is_null() { - return 1; + return 0; } // Require an unsafe block to read the version from a C string. The pointer @@ -93,7 +93,7 @@ pub extern "C" fn protocol_list_supports_protocol( let protocol_list = match c_str.to_str() { Ok(n) => n, - Err(_) => return 1, + Err(_) => return 0, }; let proto_entry: UnvalidatedProtoEntry = match protocol_list.parse() { Ok(n) => n, @@ -140,7 +140,7 @@ pub extern "C" fn protocol_list_supports_protocol_or_later( version: uint32_t, ) -> c_int { if c_protocol_list.is_null() { - return 1; + return 0; } // Require an unsafe block to read the version from a C string. The pointer @@ -149,7 +149,7 @@ pub extern "C" fn protocol_list_supports_protocol_or_later( let protocol_list = match c_str.to_str() { Ok(n) => n, - Err(_) => return 1, + Err(_) => return 0, }; let protocol = match translate_to_rust(c_protocol) { @@ -159,7 +159,7 @@ pub extern "C" fn protocol_list_supports_protocol_or_later( let proto_entry: UnvalidatedProtoEntry = match protocol_list.parse() { Ok(n) => n, - Err(_) => return 1, + Err(_) => return 0, }; if proto_entry.supports_protocol_or_later(&protocol.into(), &version) { |