Page MenuHomePhabricator

[bitcoin-tx]: Avoid treating overflow as OP_0
ClosedPublic

Authored by tobias_ruck on Aug 11 2025, 13:48.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCd7c68bc4c581: [bitcoin-tx]: Avoid treating overflow as OP_0
Summary

atoi and LocaleIndependentAtoi return 0 if the number couldn't be parsed. This is very unintuitive and potentially dangerous, a script like 11111111111111111111 OP_GREATERTHAN would be identical to 0 OP_GREATERTHAN.

Therefore, use ToIntegral, which returns an std::optional, which we can check for, or otherwise throw a runtime error.

Backport from core#23227.

Depends on D18472.

Test Plan

ninja check

Diff Detail

Repository
rABC Bitcoin ABC
Branch
backport-avoid-int-overflow-op_0
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34112
Build 67693: Build Difflint-circular-dependencies · build-debug · build-without-wallet · build-clang-tidy · build-clang · build-diff
Build 67692: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Aug 11 2025, 15:57