]> The Tcpdump Group git mirrors - libpcap/commitdiff
Linux netfilter queue interface: fix a warning and add a comment
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 6 Jan 2015 16:58:03 +0000 (17:58 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 6 Jan 2015 16:58:03 +0000 (17:58 +0100)
The warnings was:
./pcap-netfilter-linux.c: In function 'netfilter_read_linux':
./pcap-netfilter-linux.c:197:34: warning: 'nfg' may be used uninitialized in this function [-Wmaybe-uninitialized]

pcap-netfilter-linux.c

index 2a5812b273afb0272c124cfdd61a9ebb6bf02884..c086d949959c6359ad08569abfe2b5fe564ba8e6 100644 (file)
@@ -127,7 +127,7 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
                        const unsigned char *payload = NULL;
                        struct pcap_pkthdr pkth;
 
-                       const struct nfgenmsg *nfg;
+                       const struct nfgenmsg *nfg = NULL;
                        int id = 0;
 
                        if (handle->linktype != DLT_NFLOG) {
@@ -194,6 +194,8 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
 
                        if (type == NFQUEUE) {
                                /* XXX, possible responses: NF_DROP, NF_ACCEPT, NF_STOLEN, NF_QUEUE, NF_REPEAT, NF_STOP */
+                               /* if type == NFQUEUE, handle->linktype is always != DLT_NFLOG,
+                                  so nfg is always initialized to NLMSG_DATA(nlh). */
                                nfqueue_send_verdict(handle, ntohs(nfg->res_id), id, NF_ACCEPT);
                        }
                }