]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
eloop: Add assert() on negative fd when using select() code path
authorMaxime Bizon <mbizon@freebox.fr>
Thu, 20 Mar 2014 18:25:18 +0000 (19:25 +0100)
committerJouni Malinen <j@w1.fi>
Tue, 25 Mar 2014 22:17:07 +0000 (00:17 +0200)
Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
src/utils/eloop.c

index f83a2327ae4973fd93abfe24ba0be3622d9f47f0..2667c8c9abfc30e098dac88dd858157f9b609907 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "includes.h"
+#include <assert.h>
 
 #include "common.h"
 #include "trace.h"
@@ -14,7 +15,6 @@
 #include "eloop.h"
 
 #ifdef CONFIG_ELOOP_POLL
-#include <assert.h>
 #include <poll.h>
 #endif /* CONFIG_ELOOP_POLL */
 
@@ -374,8 +374,10 @@ static void eloop_sock_table_set_fds(struct eloop_sock_table *table,
        if (table->table == NULL)
                return;
 
-       for (i = 0; i < table->count; i++)
+       for (i = 0; i < table->count; i++) {
+               assert(table->table[i].sock >= 0);
                FD_SET(table->table[i].sock, fds);
+       }
 }
 
 
@@ -459,6 +461,7 @@ int eloop_register_sock(int sock, eloop_event_type type,
 {
        struct eloop_sock_table *table;
 
+       assert(sock >= 0);
        table = eloop_get_sock_table(type);
        return eloop_sock_table_add_sock(table, sock, handler,
                                         eloop_data, user_data);