From fa90cfd8d296503189d3075b8f1bf633204ddaa0 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 20 Mar 2019 08:30:29 +0100 Subject: gprs_ns_sns: Properly initialize sockaddr_in in gprs_nsvc_create_ip4() When putting together a sockaddr_in, we must not only set the IP address and port, but also set the address family to AF_INET. And while at it, let's zero-initialize the entire 'struct sockdadr_in'. Change-Id: I1c8d8fe7f79a2ec737baa7800247269c3271983e --- src/gb/gprs_ns_sns.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gb/gprs_ns_sns.c b/src/gb/gprs_ns_sns.c index cbaa4685..dd8d3a2d 100644 --- a/src/gb/gprs_ns_sns.c +++ b/src/gb/gprs_ns_sns.c @@ -88,6 +88,8 @@ static struct gprs_nsvc *gprs_nsvc_create_ip4(struct gprs_ns_inst *nsi, struct gprs_nsvc *nsvc; struct sockaddr_in sin; /* copy over. Both data structures use network byte order */ + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; sin.sin_addr.s_addr = ip4->ip_addr; sin.sin_port = ip4->udp_port; -- cgit v1.2.3