tomh / rpms / asterisk

Forked from rpms/asterisk 6 years ago
Clone

Blame 0006-Initialize-variables-before-calling-parse_uri.patch

b4f7035
From 9b6b7d18e81426ada53b388ae76ac81ec027203d Mon Sep 17 00:00:00 2001
b4f7035
From: Terry Wilson <twilson@digium.com>
b4f7035
Date: Mon, 17 Oct 2011 17:35:23 +0000
b4f7035
Subject: [PATCH 6/6] Initialize variables before calling parse_uri
b4f7035
b4f7035
If parse_uri was called with an empty URI, some pointers would be
b4f7035
modified and an invalid read could result. This patch avoids calling
b4f7035
parse_uri with an empty contact uri when parsing REGISTER requests.
b4f7035
b4f7035
AST-2011-012
b4f7035
b4f7035
(closes issue ASTERISK-18668)
b4f7035
b4f7035
git-svn-id: http://svn.asterisk.org/svn/asterisk/branches/1.8@341189 f38db490-d61c-443f-a65b-d21fe96a405b
b4f7035
---
b4f7035
 channels/chan_sip.c |    4 ++--
b4f7035
 1 files changed, 2 insertions(+), 2 deletions(-)
b4f7035
b4f7035
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
b4f7035
index 5dedd59..f786ce1 100644
b4f7035
--- a/channels/chan_sip.c
b4f7035
+++ b/channels/chan_sip.c
b4f7035
@@ -13796,7 +13796,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
b4f7035
 	char data[SIPBUFSIZE];
b4f7035
 	const char *expires = sip_get_header(req, "Expires");
b4f7035
 	int expire = atoi(expires);
b4f7035
-	char *curi, *domain, *transport;
b4f7035
+	char *curi = NULL, *domain = NULL, *transport = NULL;
b4f7035
 	int transport_type;
b4f7035
 	const char *useragent;
b4f7035
 	struct ast_sockaddr oldsin, testsa;
b4f7035
@@ -13874,7 +13874,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
b4f7035
 	ast_string_field_build(pvt, our_contact, "<%s>", curi);
b4f7035
 
b4f7035
 	/* Make sure it's a SIP URL */
b4f7035
-	if (parse_uri_legacy_check(curi, "sip:,sips:", &curi, NULL, &domain, &transport)) {
b4f7035
+	if (ast_strlen_zero(curi) || parse_uri_legacy_check(curi, "sip:,sips:", &curi, NULL, &domain, &transport)) {
b4f7035
 		ast_log(LOG_NOTICE, "Not a valid SIP contact (missing sip:/sips:) trying to use anyway\n");
b4f7035
 	}
b4f7035
 
b4f7035
-- 
b4f7035
1.7.6.4
b4f7035