]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make code path easier for static analyzers
authorJouni Malinen <j@w1.fi>
Sun, 2 Mar 2014 11:37:11 +0000 (13:37 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 2 Mar 2014 15:15:11 +0000 (17:15 +0200)
record->type == NULL case was handled through the record->type_length
comparison. While this was correct, it is a bit difficult for static
analyzers to understand, so add an extra check for NULL to avoid false
reports on this.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/wps/ndef.c

index 2b3506476e1312c5cd0bf65aebb61694c1eb67ce..d45dfc8efee645de1fc217656b1ffb4923ac56f0 100644 (file)
@@ -148,7 +148,8 @@ static struct wpabuf * ndef_build_record(u8 flags, void *type,
 
 static int wifi_filter(struct ndef_record *record)
 {
-       if (record->type_length != os_strlen(wifi_handover_type))
+       if (record->type == NULL ||
+           record->type_length != os_strlen(wifi_handover_type))
                return 0;
        if (os_memcmp(record->type, wifi_handover_type,
                      os_strlen(wifi_handover_type)) != 0)
@@ -173,7 +174,8 @@ struct wpabuf * ndef_build_wifi(const struct wpabuf *buf)
 
 static int p2p_filter(struct ndef_record *record)
 {
-       if (record->type_length != os_strlen(p2p_handover_type))
+       if (record->type == NULL ||
+           record->type_length != os_strlen(p2p_handover_type))
                return 0;
        if (os_memcmp(record->type, p2p_handover_type,
                      os_strlen(p2p_handover_type)) != 0)