aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2019-03-15 14:59:14 +0100
committerAndreas Schneider <asn@samba.org>2019-03-21 08:42:57 +0100
commitbd951c1f6944011bb5585cb58c92ca5cd5b78489 (patch)
tree5171b2b822ee2f55ad3c034e2367066d911965ae
parent6e1ed1da3f4372b7de69c5f8be227d85727b2b59 (diff)
downloadsocket_wrapper-bd951c1f6944011bb5585cb58c92ca5cd5b78489.tar.gz
socket_wrapper-bd951c1f6944011bb5585cb58c92ca5cd5b78489.tar.xz
socket_wrapper-bd951c1f6944011bb5585cb58c92ca5cd5b78489.zip
swrap: Add paranoia NULL checks
csbuild complains about missing NULL checks here. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--src/socket_wrapper.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 193f1f0..7841c85 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -2572,6 +2572,11 @@ static uint8_t *swrap_pcap_packet_init(struct timeval *tval,
i.ptr = buf;
switch (src->sa_family) {
case AF_INET:
+ if (src_in == NULL || dest_in == NULL) {
+ SAFE_FREE(base);
+ return NULL;
+ }
+
i.ip->v4.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
i.ip->v4.tos = 0x00;
i.ip->v4.packet_length = htons(wire_len - icmp_truncate_len);
@@ -2587,6 +2592,11 @@ static uint8_t *swrap_pcap_packet_init(struct timeval *tval,
break;
#ifdef HAVE_IPV6
case AF_INET6:
+ if (src_in6 == NULL || dest_in6 == NULL) {
+ SAFE_FREE(base);
+ return NULL;
+ }
+
i.ip->v6.ver_prio = 0x60; /* version 4 and 5 * 32 bit words */
i.ip->v6.flow_label_high = 0x00;
i.ip->v6.flow_label_low = 0x0000;