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

fuzz: Fix wallet_bdb_parser 32-bit unhandled fseek error #30307

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jun 19, 2024

std::fseek on 64-bit past the end of the file may work fine (the following read would fail). However, on 32-bit it may fail early.

Fix it, by ignoring the error, treating it similar to a read error.

This was found by OSS-Fuzz.

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69414

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 19, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, brunoerg

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot DrahtBot added the Tests label Jun 19, 2024
@maflcko
Copy link
Member Author

maflcko commented Jun 19, 2024

Example:

$ base64 ~/Downloads/clusterfuzz-testcase-minimized-wallet_bdb_parser-5937261974716416 
ICD//yAgICAAAAAAAAUxYgAAAAkAAAIAAAkgICAgICAAAAAAICAgICAgICAgICAgAAAAIP//ICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICD/ICAgICAg////////ICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAg////ICD//yAgICAgICAgICAgICAgICAgICAg////////
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg////ICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIP///yAgICAg
ICAgICAg////IP//////ICAgICAgICAg//8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICD///8g//////8gICAgICAgICD//yAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg////ICAgIP//IP//////ICAgICAg
ICAg//8gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA=

To test locally:

CONFIG_SITE="$PWD/depends/i686-pc-linux-gnu/share/config.site" ./configure  --enable-fuzz --with-sanitizers=fuzzer && make clean && make  -j $(nproc)
FUZZ=wallet_bdb_parser ./src/test/fuzz/fuzz -runs=1 /tmp/c

Before:

terminate called after throwing an instance of 'std::runtime_error'
  what():  AutoFile::seek: fseek failed: iostream error

After:

(Passes)

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa7bc9b

Copy link
Contributor

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK fa7bc9b

@fanquake fanquake merged commit aa2ce2d into bitcoin:master Jun 20, 2024
16 checks passed
@maflcko maflcko deleted the 2406-fuzz-wallet-bdb-32 branch June 20, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants