-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic when string field occurs more than once
Also add test Thanks to `cargo fuzz` which revealed this problem
- Loading branch information
1 parent
bb517a6
commit 28adf07
Showing
3 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! Test when two messages are concatenated, singular fields are taken from the last one. | ||
use super::test_singular_concat_pb::*; | ||
|
||
use protobuf_test_common::*; | ||
|
||
#[test] | ||
fn test_concat_bytes() { | ||
let mut m = TestSingularConcat::new(); | ||
m.set_b(b"\xdd\xee".to_vec()); | ||
|
||
test_deserialize("12 03 aa bb cc 12 02 dd ee", &m); | ||
} | ||
|
||
#[test] | ||
fn test_concat_string() { | ||
let mut m = TestSingularConcat::new(); | ||
m.set_s("\x61\x62".to_string()); | ||
|
||
test_deserialize("0a 03 21 22 23 0a 02 61 62", &m); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto2"; | ||
|
||
package test_singular_concar; | ||
|
||
message TestSingularConcat { | ||
optional string s = 1; | ||
optional bytes b = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters