litecoincash-project / litecoincash

Main release & integration tree for Litecoin Cash
https://litecoinca.sh
MIT License
54 stars 39 forks source link

A 'sizeof' for a pointer issue #10

Open QiAnXinCodeSafe opened 6 years ago

QiAnXinCodeSafe commented 6 years ago

Hi all, There is a sizeof issue found by Qihoo360 CodeSafe Team. Details as bellow:

https://github.com/litecoincash-project/litecoincash/blob/3bcc790cacad47421848d821b9ba18d8c86a5f7b/src/test/serialize_tests.cpp#L363

the argument of macro 'FLATDATA' is charstrval which is a pointer defined here: https://github.com/litecoincash-project/litecoincash/blob/3bcc790cacad47421848d821b9ba18d8c86a5f7b/src/test/serialize_tests.cpp#L347

in the expand of macro 'FLATDATA' here: https://github.com/litecoincash-project/litecoincash/blob/3bcc790cacad47421848d821b9ba18d8c86a5f7b/src/serialize.h#L354 the parameter 'obj' will be used in sizeof operator. do we really need the size of a pointer of should it be the size of the string (like strlen, or sizeof of a char array )?

Can you guys confirm this?

Cheers Qihoo360 CodeSafe Team

litecoincash-project commented 6 years ago

Thanks, we'll take a look!

blockester commented 3 years ago

Maybe the 'charstrval' and FLATDATA should simply be replaced with 'stringval'. CDataStream ss2(SER_DISK, PROTOCOL_VERSION, intval, boolval, stringval, charstrval, txval);