]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Avoid 0-length memmove from buffer end to keep static analyzers happier
authorJouni Malinen <j@w1.fi>
Thu, 17 Nov 2011 17:54:26 +0000 (19:54 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 17 Nov 2011 17:54:26 +0000 (19:54 +0200)
This avoid incorrect errors from some static analyzers that do not like
memmove with pointers just after the end of a buffer even if the number
of bytes to move is zero.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/eap_server/eap_server.c

index 0f0da29d60e0d4a5b3d6f936253a91fad53b6949..4483508ceb4066b0bb14fdd2da8082707622c313 100644 (file)
@@ -1028,9 +1028,12 @@ void eap_sm_process_nak(struct eap_sm *sm, const u8 *nak_list, size_t len)
 
        not_found:
                /* not found - remove from the list */
-               os_memmove(&sm->user->methods[i], &sm->user->methods[i + 1],
-                          (EAP_MAX_METHODS - i - 1) *
-                          sizeof(sm->user->methods[0]));
+               if (i + 1 < EAP_MAX_METHODS) {
+                       os_memmove(&sm->user->methods[i],
+                                  &sm->user->methods[i + 1],
+                                  (EAP_MAX_METHODS - i - 1) *
+                                  sizeof(sm->user->methods[0]));
+               }
                sm->user->methods[EAP_MAX_METHODS - 1].vendor =
                        EAP_VENDOR_IETF;
                sm->user->methods[EAP_MAX_METHODS - 1].method = EAP_TYPE_NONE;