Conversion error between little-endian and big-endian data formats
V530 CWE-252 The return value of function ‘bswap32’ is required to be utilized. ELFAttribute.cpp 84
inline uint32_t bswap32(uint32_t pData) { return (((pData & 0xFF000000) >> 24) | ((pData & 0x00FF0000) >> 8) | ((pData & 0x0000FF00) << 8) | ((pData & 0x000000FF) << 24)); } bool ELFAttribute::merge(....) { .... uint32_t subsection_length = *reinterpret_cast<const uint32_t*>(subsection_data); if (llvm::sys::IsLittleEndianHost != m_Config.targets().isLittleEndian()) bswap32(subsection_length); .... }
There are no claims against the function bswap32. But its usage is incorrect.
bswap32(subsection_length);
The author assumes that the variable is passed to the function by reference and gets changed there. However, he needs to use the value returned by the function. As a result, there is no data conversion.
Please click here to see more bugs from this project.