bitcoin-tx: Stricter check for valid integers

bitcoin-tx: Stricter check for valid integers

Just calling atoi to convert strings to integers does not check for
valid integers very thoroughly; in particular, it just ignores
everything starting from the first non-numeral character.  Even a string
like "foo" is fine and silently returns 0.

This meant that bitcoin-tx would not fail if such a string was passed in
various places where an integer is expected (like the locktime or an
input/output index); this means that it would, for instance, silently
accept a typo and interpret it in an unexpected way.

In this change, we use ParseInt64 for parsing strings to integers,
which actually verifies that the full string is valid as number.
New tests in the bitcoin-util-test cover the new error paths.

情報元 - bitcoin-tx: Stricter check for valid integers · bitcoin/[email protected] · GitHub

bitcoin-tx: Stricter check for valid integers · bitcoin/bitcoin@57889e6 · GitHub
スポンサーリンク

シェアする

フォローする

スポンサーリンク

トップへ戻る