[asterisk-commits] build: Fix ast sockaddr initialization to be more portable (asterisk[certified/11.6])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 21 07:35:36 CDT 2016


Joshua Colp has submitted this change and it was merged.

Change subject: build:  Fix ast_sockaddr initialization to be more portable
......................................................................


build:  Fix ast_sockaddr initialization to be more portable

A change to glibc 2.22 changed the order of the sockadddr_storage
members which caused the places where we do an initialization of
ast_sockaddr with '{ { 0, 0, } }' to fail compilation.  Those
initializers (which we shouldn't have been using anyway) have been
replaced with memsets.


Change-Id: Idd1b3b320903d8771bfe221f0b015685de628fa4
(cherry picked from commit fd5467ce01643e51f0f80c07af0098ab49591947)
---
M channels/chan_sip.c
M tests/test_netsock2.c
2 files changed, 6 insertions(+), 3 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 80f1189..7d7b9e4 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -15020,11 +15020,12 @@
 
 static const char *sip_sanitized_host(const char *host)
 {
-	struct ast_sockaddr addr = { { 0, 0, }, };
+	struct ast_sockaddr addr;
 
 	/* peer/sip_pvt->tohost and sip_registry->hostname should never have a port
 	 * in them, so we use PARSE_PORT_FORBID here. If this lookup fails, we return
 	 * the original host which is most likely a host name and not an IP. */
+	memset(&addr, 0, sizeof(addr));
 	if (!ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID)) {
 		return host;
 	}
diff --git a/tests/test_netsock2.c b/tests/test_netsock2.c
index e182b0a..fec1ae2 100644
--- a/tests/test_netsock2.c
+++ b/tests/test_netsock2.c
@@ -75,7 +75,7 @@
 	};
 
 	size_t x;
-	struct ast_sockaddr addr = { { 0, 0, } };
+	struct ast_sockaddr addr;
 	int parse_result;
 
 	switch (cmd) {
@@ -91,15 +91,17 @@
 	}
 
 	for (x = 0; x < ARRAY_LEN(test_vals); x++) {
+		memset(&addr, 0, sizeof(addr));
 		if ((parse_result = ast_sockaddr_parse(&addr, test_vals[x].address, 0)) != test_vals[x].expected_result) {
 			ast_test_status_update(test, "On '%s' expected %d but got %d\n", test_vals[x].address, test_vals[x].expected_result, parse_result);
 			res = AST_TEST_FAIL;
 		}
 		if (parse_result) {
-			struct ast_sockaddr tmp_addr = { { 0, 0, } };
+			struct ast_sockaddr tmp_addr;
 			const char *tmp;
 
 			tmp = ast_sockaddr_stringify(&addr);
+			memset(&tmp_addr, 0, sizeof(tmp_addr));
 			ast_sockaddr_parse(&tmp_addr, tmp, 0);
 			if (ast_sockaddr_cmp_addr(&addr, &tmp_addr)) {
 				char buf[64];

-- 
To view, visit https://gerrit.asterisk.org/3262
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idd1b3b320903d8771bfe221f0b015685de628fa4
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: certified/11.6
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list