qnighy / yasna.rs

ASN.1 library for Rust
Apache License 2.0
42 stars 31 forks source link

test_ber_read_overflow fails on i386 #72

Closed alexanderkjall closed 1 year ago

alexanderkjall commented 1 year ago

Running the testsuite on i386 (or 32bit arm) yields the following test failure:

---- reader::tests::test_ber_read_overflow stdout ----
thread 'reader::tests::test_ber_read_overflow' panicked at 'assertion failed: `(left == right)`
  left: `Eof`,
 right: `IntegerOverflow`', src/reader/tests.rs:1665:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    reader::tests::test_ber_read_overflow

arm log: https://ci.debian.net/data/autopkgtest/testing/armel/r/rust-yasna/35390290/log.gz i386 log: https://ci.debian.net/data/autopkgtest/testing/i386/r/rust-yasna/35391533/log.gz

It would be easy to gate the test to only run on 64bit, but looking at the code I feared that this might indicate a deeper problem and wanted some feedback on how to resolve it.

est31 commented 1 year ago

The test was originally found during fuzzing, see #62 . I suppose the length is overflowing on 32 bit targets as it's not representable by a 32 bit number. The line that triggers the error is probably here. I guess in order to address this test failure it would be one idea to just remove some of the 255s, at least on 32 bit targets, and then add at least one 32 bit target to CI. Edited to add: I confirm that this is not really a bug in yasna itself, but only its tests. The test is supposed to fail but errors in the wrong way.