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

VarUInt encoding is incorrect for sufficiently large u64s #689

Open
zslayton opened this issue Dec 19, 2023 · 0 comments
Open

VarUInt encoding is incorrect for sufficiently large u64s #689

zslayton opened this issue Dec 19, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@zslayton
Copy link
Contributor

In the process of comparing the encoding primitives of Ion 1.0 and 1.1 I discovered a bug in 1.0's VarUInt::write_u64. This test fails:

    #[test]
    fn roundtrip_varuint() -> IonResult<()> {
        let mut buffer = Vec::new();
        VarUInt::write_u64(&mut buffer, u64::MAX)?;
        let (var_uint, _) = ImmutableBuffer::new(buffer.as_slice()).read_var_uint()?;
        let value = var_uint.value() as u64;
        assert_eq!(value, u64::MAX);
        Ok(())
    }

Output:

assertion `left == right` failed
  left: 9223372036854775807
  right: 18446744073709551615
@zslayton zslayton added the bug Something isn't working label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant