Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
bgColor#ccccff
langc
/* 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

...

  ntohs - convert values between host and network byte order

...