Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization of empty sequences is incorrect #49

Closed
Boog900 opened this issue Jun 28, 2023 · 4 comments · Fixed by #58
Closed

Serialization of empty sequences is incorrect #49

Boog900 opened this issue Jun 28, 2023 · 4 comments · Fixed by #58

Comments

@Boog900
Copy link
Member

Boog900 commented Jun 28, 2023

If a sequence is empty the Serializer won't append a marker or it's length

example:

#[derive(Default, Deserialize, Serialize, PartialEq, Debug)]
struct TestStruct {
    seq: Vec<u32>,
}


fn test() {
    let mut obj = TestStruct::default();
    let mut data = to_bytes(&obj).unwrap();
    //assert_eq!(obj, from_bytes(&data).unwrap()); // Fails

    data.push(0x80 + 6); // Appending the marker
    data.push(0); // Appending the varint length
    assert_eq!(obj, from_bytes(&data).unwrap()); // Successful 

}
@Boog900
Copy link
Member Author

Boog900 commented Jun 28, 2023

It doesn't actually doesn't look like we are going to be able to deal with this as we wont know what marker to insert .... : (

@jeffro256
Copy link

See issue: monero-project/monero#8940. Current epee binary deserialization code doesn't care about type markers for empty sequences

@vtnerd
Copy link

vtnerd commented Jul 7, 2023

@jeffro256 the length is needed afaik ? That was the other issue @Boog900 mentioned.

@Boog900
Copy link
Member Author

Boog900 commented Jul 7, 2023

@vtnerd yep this is still an issue but its fixable now, I thought it wasn't fixable because we wouldn't know what marker to insert

This was referenced Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants