Android

android-card

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.