Page MenuHomePhabricator

Add static_assert to prevent VARINT(<signed value>)
ClosedPublic

Authored by deadalnix on Oct 1 2019, 13:43.

Details

Summary

Using VARINT with signed types is dangerous because negative values will appear
to serialize correctly, but then deserialize as positive values mod 128.

This commit changes the VARINT macro to trigger an error by default if called
with an signed value, and updates broken uses of VARINT to pass a special flag
that lets them keep working with no change in behavior.

This is a backport of Core PR9753

Test Plan
make check
./test/functional/test_runner.py --extended

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.