litecoincash icon indicating copy to clipboard operation
litecoincash copied to clipboard

A 'sizeof' for a pointer issue

Open QiAnXinCodeSafe opened this issue 6 years ago • 2 comments

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

QiAnXinCodeSafe avatar Sep 30 '18 08:09 QiAnXinCodeSafe

Thanks, we'll take a look!

litecoincash-project avatar Oct 11 '18 15:10 litecoincash-project

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

blockester avatar Jan 12 '21 06:01 blockester