iptables: A file descriptor cannot be a nagative integer
authorDanny Jeongseok Seo <s.seo@samsung.com>
Tue, 13 Nov 2012 01:44:26 +0000 (10:44 +0900)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 13 Nov 2012 12:38:27 +0000 (14:38 +0200)
When a socket() has failed and a negative file descriptor has been set,
close() cannot accept a negative number as a parameter.

src/iptables.c

index 147d604..16b665a 100644 (file)
@@ -1207,7 +1207,8 @@ static void table_cleanup(struct connman_iptables *table)
        if (table == NULL)
                return;
 
-       close(table->ipt_sock);
+       if (table->ipt_sock >= 0)
+               close(table->ipt_sock);
 
        for (list = table->entries; list; list = list->next) {
                entry = list->data;