Travis is currently failing because of missing test fixtures from #7957.
This PR adds the two missing fixture files to the Makefile.test.include.
Travis is currently failing because of missing test fixtures from #7957.
This PR adds the two missing fixture files to the Makefile.test.include.
Hmm, doesn't this call for generalization? Ie. to not need to name the files in this directory?
205 | @@ -206,7 +206,7 @@ static void MutateTxAddInput(CMutableTransaction& tx, const string& strInput) 206 | // extract the optional sequence number 207 | uint32_t nSequenceIn=std::numeric_limits<unsigned int>::max(); 208 | if (vStrInputParts.size() > 2) 209 | - nSequenceIn = atoi(vStrInputParts[2]); 210 | + nSequenceIn = std::stoul(vStrInputParts[2]);
This should be stored to an unsigned long and checked against std::numeric_limits<uint32_t>::max() just to be safe, otherwise invalid values will wrap and be quietly accepted. To be doubly safe, it'd need to use strtoll and check errno and negatives :.
I'm unsure what amount of paranoia is called for here.
IMO we only support platforms/archs where int is always 32bit and I think std::numeric_limits<uint32_t>::max() won't change much.
@jonasschnelli These are the cases I'm worried about (running on current master):
./bitcoin-tx 01000000000000000000 in=838af7eea675044a35a646f937ba26c412e4db51dc2b155c45f5c2675acd0cae:1:-1
0100000001ae0ccd5a67c2f5455c152bdc51dbe412c426ba37f946a6354a0475a6eef78a830100000000ffffffff0000000000
./bitcoin-tx 01000000000000000000 in=838af7eea675044a35a646f937ba26c412e4db51dc2b155c45f5c2675acd0cae:1:4294967296
0100000001ae0ccd5a67c2f5455c152bdc51dbe412c426ba37f946a6354a0475a6eef78a830100000000000000000000000000
In order to be able to test for those cases on the worst-case platform (win64), you need to store the input as a signed long long, since a signed long isn't big enough there.
why not use ParseInt32, a function I especially wrote for this purpose and does the necessary checking? Edit: as discused on IRC we really need a ParseUInt32, going to write one
Right. ParseInt32 would be better. I guess it would require a ParseIntU32. This can be done in a later PR and also changes the rest of bitcoin-tx (there are servals atoi() and atoi64).
For the sake of unborking master, ACK https://github.com/bitcoin/bitcoin/pull/8164/commits/86efa30ae3fd36aa77b19ff0f70bb89be9ec308e. I'll address my complaints in a follow-up.