]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Switch from ntohs() to fr_nbo_to_uint16() (CID #1243443)
authorJames Jones <jejones3141@gmail.com>
Thu, 17 Aug 2023 19:34:23 +0000 (14:34 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 17 Aug 2023 19:57:46 +0000 (13:57 -0600)
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.

src/lib/eap/session.c

index a73b7df564bd7a931682a8a555d0c1a43f286ba7..77c946f8a6e4f9baf46cb7a1c20522e51ec6b1b5 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include <freeradius-devel/server/pair.h>
 #include <freeradius-devel/radius/radius.h>
+#include <freeradius-devel/util/nbo.h>
 
 #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.