Missing byte reordering when transferring data
Different endianness of host and network
Description
This defect occurs when you do not use a byte ordering function:
Before sending data to a network socket.
After receiving data from a network socket.
Risk
Some system architectures implement little endian byte ordering (least significant byte first), and other systems implement big endian (most significant byte first). If the endianness of the sent data does not match the endianness of the receiving system, the value returned when reading the data is incorrect.
Fix
After receiving data from a socket, use a byte ordering function such as
ntohl(). Before sending data to a socket, use a byte ordering function
such as htonl().
Examples
Result Information
| Group: Programming |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax:
MISSING_BYTESWAP
|
| Impact: Medium |
PQL Name:
std.defects.MISSING_BYTESWAP
|
Version History
Introduced in R2017b
See Also
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)