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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

nakihito created this revision.Jan 28 2020, 19:41
Owners added a reviewer: Restricted Owners Package.Jan 28 2020, 19:41
Herald added a reviewer: Restricted Project. · View Herald TranscriptJan 28 2020, 19:41
jasonbcox added inline comments.
src/seeder/dns.cpp
68 ↗(On Diff #15850)

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

nakihito added inline comments.Jan 28 2020, 23:35
src/seeder/dns.cpp
68 ↗(On Diff #15850)

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.

jasonbcox accepted this revision.Jan 29 2020, 01:42
This revision is now accepted and ready to land.Jan 29 2020, 01:42
nakihito updated this revision to Diff 16506.Feb 25 2020, 21:51

Rebased in light of changes to D4418.

nakihito updated this revision to Diff 16713.Mar 2 2020, 23:26

Rebased.

This revision was automatically updated to reflect the committed changes.