...
This program prints out the number received from the socket using an incorrect byte ordering. For example, if the value 4 is sent from a big endian machine, and the receiving system is little endian, the value 536,870,912 is read. This problem can be corrected by sending and receiving using network byte ordering.
Compliant
...
Solution
In this compliant code examplesolution, the programmer uses the ntohl() function to convert the integer from network byte order to host byte ordering:
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level | |
|---|---|---|---|---|---|---|
POS39-C | mediumMedium | likelyLikely | lowLow | P18 | L1 |
|
Bibliography
| [MSDN] | "Winsock Functions" |
| [Open Group 2004] | htonl, htons, ntohl, ntohs—Convert Values between Host and Network Byte Order |
...