...
In this compliant code example, the programmer uses the ntohl() function to convert the integer from network byte order to host byte ordering.:
| Code Block | ||||
|---|---|---|---|---|
| ||||
/* sock is a connected TCP socket */
uint32_t num;
if (recv(sock, (void *)&num, sizeof(uint32_t), 0) < 0) {
/* Handle error */
}
num = ntohl(num);
printf("We recieved %u from the network!\n", (unsigned int)num);
|
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level | |
|---|---|---|---|---|---|---|
POS39-C | medium | likely | low | P18 | L1 |
|
...
Bibliography
...
| Functions" | |
| [Open Group 2004] | htonl, htons, ntohl, ntohs—Convert Values between Host and Network Byte Order |
ntohs - convert values between host and network byte order
...