Page MenuHomePhabricator

Handle invalid hex encoding in ParseHex
ClosedPublic

Authored by PiRK on Mon, Nov 18, 11:10.

Details

Reviewers
roqqit
Group Reviewers
Restricted Project
Commits
rABC17760e91d644: Handle invalid hex encoding in ParseHex
Summary

Seems a bit confusing to happily accept random bytes and pretend they are hex encoded strings

Added a new TryParseHex function returning an optional. The old function remains an alias, with the fallback to an empty vector. This avoid having to change all existing code and making it needlessly verbose, because it is already properly handling empty vectors.

This is a backport of core#25227

Fix a hex string in checkpoints_tests that was obviously wrong (odd number of hex chars) and now causes ParseHex to return an empty vector.

Depends on D17157

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Mon, Nov 18, 11:10
This revision is now accepted and ready to land.Mon, Nov 18, 17:22