From: James Jones Date: Thu, 17 Aug 2023 19:34:23 +0000 (-0500) Subject: Switch from ntohs() to fr_nbo_to_uint16() (CID #1243443) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1595fcc2b91e304f650e4efb0e80f5e2edd654e6;p=thirdparty%2Ffreeradius-server.git Switch from ntohs() to fr_nbo_to_uint16() (CID #1243443) Takes advantage of coverity thinking fr_nbo_to_foo() taints the passed pointer, which here is it's only use, while the returned value is used several times. --- diff --git a/src/lib/eap/session.c b/src/lib/eap/session.c index a73b7df564b..77c946f8a6e 100644 --- a/src/lib/eap/session.c +++ b/src/lib/eap/session.c @@ -23,6 +23,7 @@ */ #include #include +#include #include "attrs.h" #include "compose.h" @@ -234,8 +235,7 @@ static char *eap_identity(request_t *request, eap_session_t *eap_session, eap_pa (eap_packet->code != FR_EAP_CODE_RESPONSE) || (eap_packet->data[0] != FR_EAP_METHOD_IDENTITY)) return NULL; - memcpy(&len, eap_packet->length, sizeof(uint16_t)); - len = ntohs(len); + len = fr_nbo_to_uint16(eap_packet->length); /* * Note: The minimum length here is 5.