summaryrefslogtreecommitdiff
path: root/src/rust/protover
AgeCommit message (Collapse)Author
2018-09-24rust: run rustfmtcypherpunks
2018-09-18Merge branch 'maint-0.3.4'Nick Mathewson
2018-09-18Merge branch 'maint-0.3.3' into maint-0.3.4Nick Mathewson
2018-09-16Don't try to link C from rust doctests for nss detectionNick Mathewson
This is really annoying, since we can't use cfg(test) for doctests.
2018-09-16When Tor is compiled with NSS, don't claim support for LinkAuth=1Nick Mathewson
Closes ticket 27288
2018-09-14rust/protover: delete ProtoSet::retaincypherpunks
As the comment noted, it was horribly inefficient.
2018-09-14rust/protover: use .and_not_in() instead of .retain() in all_supported()cypherpunks
.retain() would allocating a Vec of billions of integers and check them one at a time to separate the supported versions from the unsupported. This leads to a memory DoS. Closes ticket 27206. Bugfix on e6625113c98c281b0a649598d7daa347c28915e9.
2018-09-14rust/protover: add ProtoSet::and_not_in()cypherpunks
This is a way more efficient version of retain().
2018-09-14Merge branch 'maint-0.3.3' into maint-0.3.4Nick Mathewson
2018-09-14Merge branch 'rust-protokeyword1-034' into rust-protokeyword1-035cypherpunks
2018-09-14Merge branch 'rust-protokeyword1' into rust-protokeyword1-034cypherpunks
2018-09-13rust/protover: validate unknown protocol names use only allowed characterscypherpunks
2018-09-12Merge branch 'maint-0.3.4'Nick Mathewson
2018-09-12Merge branch 'maint-0.3.3' into maint-0.3.4Nick Mathewson
2018-09-12rust/protover: fix check for overlapping rangescypherpunks
Closes ticket 27649. Bugfix on e6625113c98c281b0a649598d7daa347c28915e9.
2018-09-12rust/protover: remove version zero from testscypherpunks
This isn't legal according to dir-spec.txt. We can write separate tests for it if the spec is changed to make it legal.
2018-08-17Merge branch 'maint-0.3.3' into maint-0.3.4Nick Mathewson
2018-08-17Merge branch 'maint-0.3.4'Nick Mathewson
2018-08-17Merge remote-tracking branch 'onionk/rust-protospace' into maint-0.3.3Nick Mathewson
2018-08-17rust/protover: don't accept whitespace in ProtoSet::from_str()cypherpunks
It's impossible for spaces to get here, since spaces are used as separators between individual protocol entries higher up. And it shouldn't ignore whitespace that isn't a literal space character, because that would differ from the C implementation. These were added in 9925d2e68709aa7346f4c5bc98ea1349df6741f3. Fixes #27177. Bugfix on 0.3.3.5-rc.
2018-08-17Merge branch 'maint-0.3.3' into maint-0.3.4Nick Mathewson
2018-08-17Merge branch 'maint-0.3.4'Nick Mathewson
2018-08-17rust/protover: fix hyphen parsing bug in ProtoSet::from_str()cypherpunks
It was parsing "1-2-3" as if it were 1-2, ignoring the 2nd hyphen and everything after. Introduced in d1820c1516a31a149fc51a9e5126bf899e4c4e08. Fixes #27164; bugfix on 0.3.3.1-alpha.
2018-08-17rust/protover: fix docs for UnvalidatedProtoEntry::from_strcypherpunks
This got shuffled around in b786b146edd33b025774819f54d7bba3d07bf832 and hasn't been accurate since 124caf28e6db1e7bf8cdfef25c55760c81fb91b5.
2018-08-17rust/protover: fix parsing docscypherpunks
The function takes an already validated utf-8 string, and it never checks if the version numbers are an empty string. That parse error happens later. Fix on 701c2b69f52cb4db46aa7455904e518b35fafc1a
2018-08-17rust/protover: fix ProtoEntry::from_str docscypherpunks
Texxt was copied from a function that returned a single tuple in 88b2f170e451567a3b0095a420544a675a5826b0.
2018-08-16rust: run rustfmtcypherpunks
2018-08-16rust/docs: fix critical typo for missing_docs lintcypherpunks
Fix typo from fe66d06a45a4714141eba992fe87ec3dd5fa1c22. The exclamation point is what lets an attribute apply to an entire crate, without the ! it's practically a placebo. Fix on commits af182d4ab51d6a1a70559bbdcd4ab842aa855684 and b6059297d7cb76f0e00e2098e38d6677d3033340, and note there are still missing docs in both crypto and protover, for now. https://doc.rust-lang.org/reference/attributes.html
2018-07-13Merge remote-tracking branch 'tor-github/pr/179'Nick Mathewson
2018-07-05Fix everything that previously referred to src/orNick Mathewson
2018-06-25Run rustfmt on 'src/rust/protover/ffi.rs'.Corey Farwell
2018-06-24Utilize type param in method invocation.Corey Farwell
2018-06-24Utilize `if..else` for switching on boolean values.Corey Farwell
2018-06-24Utilize `if let` construct instead of explicit unwrapping.Corey Farwell
2018-06-24Change `allocate_and_copy_string` to take a `&str` instead of `&String`.Corey Farwell
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-06-20rust: Remove redundant "testing" feature from tor_log crate.Isis Lovecruft
It was synonymous with the builtin "test" feature. * FIXES #26399: https://bugs.torproject.org/26399
2018-05-22Merge branch 'maint-0.3.3'Nick Mathewson
2018-05-22Make the TROVE-2018-005 fix work with rust.Nick Mathewson
2018-05-22rust: Mirror TROVE-2018-005 fix in Rust protover implementation.Isis Lovecruft
* REFACTORS `UnvalidatedProtoEntry::from_str` to place the bulk of the splitting/parsing logic in to a new `UnvalidatedProtoEntry::parse_protocol_and_version_str()` method (so that both `from_str()` and `from_str_any_len()` can call it.) * ADD a new `UnvalidatedProtoEntry::from_str_any_len()` method in order to maintain compatibility with consensus methods older than 29. * ADD a limit on the number of characters in a protocol name. * FIXES part of #25517: https://bugs.torproject.org/25517
2018-05-22rust: Mirror TROVE-2018-005 fix in Rust protover implementation.Isis Lovecruft
* REFACTORS `UnvalidatedProtoEntry::from_str` to place the bulk of the splitting/parsing logic in to a new `UnvalidatedProtoEntry::parse_protocol_and_version_str()` method (so that both `from_str()` and `from_str_any_len()` can call it.) * ADD a new `UnvalidatedProtoEntry::from_str_any_len()` method in order to maintain compatibility with consensus methods older than 29. * ADD a limit on the number of characters in a protocol name. * FIXES part of #25517: https://bugs.torproject.org/25517
2018-04-02rust: Fix ProtoSet and ProtoEntry to use the same DoS limits as C.Isis Lovecruft
Previously, the limit for MAX_PROTOCOLS_TO_EXPAND was actually being applied in Rust to the maximum number of version (total, for all subprotocols). Whereas in C, it was being applied to the number of subprotocols that were allowed. This changes the Rust to match C's behaviour.
2018-04-02rust: Port all C protover_all_supported tests to Rust.Isis Lovecruft
The behaviours still do not match, unsurprisingly, but now we know where a primary difference is: the Rust is validating version ranges more than the C, so in the C it's possible to call protover_all_supported on a ridiculous version range like "Sleen=0-4294967294" because the C uses MAX_PROTOCOLS_TO_EXPAND to count the number of *subprotocols* whereas the Rust uses it to count the total number of *versions* of all subprotocols.
2018-04-02rust: Refactor protover::compute_for_old_tor().Isis Lovecruft
During code review and discussion with Chelsea Komlo, she pointed out that protover::compute_for_old_tor() was a public function whose return type was `&'static CStr`. We both agree that C-like parts of APIs should: 1. not be exposed publicly (to other Rust crates), 2. only be called in the appropriate FFI code, 3. not expose types which are meant for FFI code (e.g. `*mut char`, `CString`, `*const c_int`, etc.) to the pure-Rust code of other crates. 4. FFI code (e.g. things in `ffi.rs` modules) should _never_ be called from pure-Rust, not even from other modules in its own crate (i.e. do not call `protover::ffi::*` from anywhere in `protover::protoset::*`, etc). With that in mind, this commit makes the following changes: * CHANGE `protover::compute_for_old_tor()` to be visible only at the `pub(crate)` level. * RENAME `protover::compute_for_old_tor()` to `protover::compute_for_old_tor_cstr()` to reflect the last change. * ADD a new `protover::compute_for_old_tor()` function wrapper which is public and intended for other Rust code to use, which returns a `&str`.
2018-04-02rust: Refactor Rust implementation of protover_is_supported_here().Isis Lovecruft
It was changed to take borrows instead of taking ownership. * REFACTOR `protover::ffi::protover_is_supported_here()` to use changed method signature on `protover::is_supported_here()`.
2018-04-02rust: Refactor Rust impl of protover_compute_vote().Isis Lovecruft
This includes a subtle difference in behaviour to the previous Rust implementation, where, for each vote that we're computing over, if a single one fails to parse, we skip it. This now matches the current behaviour in the C implementation. * REFACTOR `protover::ffi::protover_compute_vote()` to use new types and methods.
2018-04-02rust: Refactor Rust impl of protover_list_supports_protocol_or_later().Isis Lovecruft
This includes a subtle difference in behaviour, as in 4258f1e18, where we return (matching the C impl's return behaviour) earlier than before if parsing failed, saving us computation in parsing the versions into a protover::protoset::ProtoSet. * REFACTOR `protover::ffi::protover_list_supports_protocol_or_later()` to use new types and methods.
2018-04-02rust: Refactor Rust impl of protover_list_supports_protocol().Isis Lovecruft
This includes a subtle difference in behaviour, as in 4258f1e18, where we return (matching the C impl's return behaviour) earlier than before if parsing failed, saving us computation in parsing the versions into a protover::protoset::ProtoSet. * REFACTOR `protover::ffi::protover_list_supports_protocol()` to use new types and methods.
2018-04-02rust: Refactor Rust impl of protover_all_supported().Isis Lovecruft
This includes differences in behaviour to before, which should now more closely match the C version: - If parsing a protover `char*` from C, and the string is not parseable, this function will return 1 early, which matches the C behaviour when protocols are unparseable. Previously, we would parse it and its version numbers simultaneously, i.e. there was no fail early option, causing us to spend more time unnecessarily parsing versions. * REFACTOR `protover::ffi::protover_all_supported()` to use new types and methods.
2018-04-02rust: Refactor protover tests with new methods; note altered behaviours.Isis Lovecruft
Previously, the rust implementation of protover considered an empty string to be a valid ProtoEntry, while the C version did not (it must have a "=" character). Other differences include that unknown protocols must now be parsed as `protover::UnknownProtocol`s, and hence their entries as `protover::UnvalidatedProtoEntry`s, whereas before (nearly) all protoentries could be parsed regardless of how erroneous they might be considered by the C version. My apologies for this somewhat messy and difficult to read commit, if any part is frustrating to the reviewer, please feel free to ask me to split this into smaller changes (possibly hard to do, since so much changed), or ask me to comment on a specific line/change and clarify how/when the behaviours differ. The tests here should more closely match the behaviours exhibited by the C implementation, but I do not yet personally guarantee they match precisely. * REFACTOR unittests in protover::protover. * ADD new integration tests for previously untested behaviour. * FIXES part of #24031: https://bugs.torproject.org/24031.