[tor-commits] [tor/master] protover: Add missing Padding to translate_to_rust

nickm at torproject.org nickm at torproject.org
Tue Mar 5 18:00:16 UTC 2019


commit a999cb43df3dc4e64820347486a2d861636bfc2e
Author: David Goulet <dgoulet at torproject.org>
Date:   Fri Mar 1 13:50:00 2019 -0500

    protover: Add missing Padding to translate_to_rust
    
    This commit also explicitly set the value of the PRT enum so we can match/pin
    the C enum values to the Rust one in protover/ffi.rs.
    
    Fixes #29631
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 changes/ticket29631      |  4 ++++
 src/core/or/protover.h   | 22 +++++++++++-----------
 src/rust/protover/ffi.rs |  1 +
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/changes/ticket29631 b/changes/ticket29631
new file mode 100644
index 000000000..9fc194ba9
--- /dev/null
+++ b/changes/ticket29631
@@ -0,0 +1,4 @@
+  o Minor bugfixes (Rust, protover):
+    - The Rust implementation of protover was missing the "Padding" value in
+      the translate function from C to Rust. Fixes bug 29631; bugfix on
+      0.4.0.1-alpha.
diff --git a/src/core/or/protover.h b/src/core/or/protover.h
index 27106d4be..567b94a16 100644
--- a/src/core/or/protover.h
+++ b/src/core/or/protover.h
@@ -33,17 +33,17 @@ struct smartlist_t;
 /// C_RUST_COUPLED: src/rust/protover/ffi.rs `translate_to_rust`
 /// C_RUST_COUPLED: src/rust/protover/protover.rs `Proto`
 typedef enum protocol_type_t {
-  PRT_LINK,
-  PRT_LINKAUTH,
-  PRT_RELAY,
-  PRT_DIRCACHE,
-  PRT_HSDIR,
-  PRT_HSINTRO,
-  PRT_HSREND,
-  PRT_DESC,
-  PRT_MICRODESC,
-  PRT_CONS,
-  PRT_PADDING,
+  PRT_LINK      = 0,
+  PRT_LINKAUTH  = 1,
+  PRT_RELAY     = 2,
+  PRT_DIRCACHE  = 3,
+  PRT_HSDIR     = 4,
+  PRT_HSINTRO   = 5,
+  PRT_HSREND    = 6,
+  PRT_DESC      = 7,
+  PRT_MICRODESC = 8,
+  PRT_CONS      = 9,
+  PRT_PADDING   = 10,
 } protocol_type_t;
 
 bool protover_contains_long_protocol_names(const char *s);
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs
index 6ee63adb1..066b08edd 100644
--- a/src/rust/protover/ffi.rs
+++ b/src/rust/protover/ffi.rs
@@ -30,6 +30,7 @@ fn translate_to_rust(c_proto: uint32_t) -> Result<Protocol, ProtoverError> {
         7 => Ok(Protocol::Desc),
         8 => Ok(Protocol::Microdesc),
         9 => Ok(Protocol::Cons),
+        10 => Ok(Protocol::Padding),
         _ => Err(ProtoverError::UnknownProtocol),
     }
 }





More information about the tor-commits mailing list