Page MenuHomePhabricator

Make parse_name() fail when passed buffer size = 0
ClosedPublic

Authored by nakihito on Jan 28 2020, 19:41.

Details

Reviewers
jasonbcox
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rSTAGINGb9c35cfd6406: Make parse_name() fail when passed buffer size = 0
rABCb9c35cfd6406: Make parse_name() fail when passed buffer size = 0
Summary

Currently, if you pass an output buffer size of 0 to parse_name() it will
cause an overflow when checking the output buffer space. This change causes the
function to short-circuit and fail when passed a buffer size of 0 instead.

Also adds a test for this scenario.

Depends on D4418

Test Plan
ninja check-bitcoin-seeder

Diff Detail

Repository
rABC Bitcoin ABC
Branch
FixWriteBufferGuard
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 9177
Build 16306: Default Diff Build & Tests
Build 16305: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Jan 28 2020, 19:41
jasonbcox added inline comments.
src/seeder/dns.cpp
68

Do we know what using a -2 return code means vs -1?

src/seeder/dns.cpp
68

https://reviews.bitcoinabc.org/source/bitcoin-abc/browse/master/src/seeder/dns.h$32-35
Basically, -2 is output buffer error while -1 is input string error.

This revision is now accepted and ready to land.Jan 29 2020, 01:42

Rebased in light of changes to D4418.