Package: belle-sip / 1.6.3-5

authfix-missing-nonce-1.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 7dd8397f0fd24bc3ddf04986488241b1acaf5a94 Mon Sep 17 00:00:00 2001
From: Erwan Croze <erwan.croze@belledonne-communications.com>
Date: Mon, 17 Dec 2018 08:48:46 +0100
Subject: [PATCH] Fix strcmp on a NULL char* in
 authorization_context_fill_from_auth

---
 src/provider.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/provider.c b/src/provider.c
index db5345d4..3c3b2f4a 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -1040,12 +1040,13 @@ void belle_sip_provider_remove_server_transaction(belle_sip_provider_t *prov, be
 
 
 static void authorization_context_fill_from_auth(authorization_context_t* auth_context,belle_sip_header_www_authenticate_t* authenticate,belle_sip_uri_t *from_uri) {
+	const char *nonce = belle_sip_header_www_authenticate_get_nonce(authenticate);
 	authorization_context_set_realm(auth_context,belle_sip_header_www_authenticate_get_realm(authenticate));
-	if (auth_context->nonce && strcmp(belle_sip_header_www_authenticate_get_nonce(authenticate),auth_context->nonce)!=0) {
+	if (auth_context->nonce && nonce && strcmp(nonce, auth_context->nonce) != 0) {
 		/*new nonce, resetting nounce_count*/
 		auth_context->nonce_count=0;
+		authorization_context_set_nonce(auth_context, nonce);
 	}
-	authorization_context_set_nonce(auth_context,belle_sip_header_www_authenticate_get_nonce(authenticate));
 	authorization_context_set_algorithm(auth_context,belle_sip_header_www_authenticate_get_algorithm(authenticate));
 	authorization_context_set_qop(auth_context,belle_sip_header_www_authenticate_get_qop_first(authenticate));
 	authorization_context_set_scheme(auth_context,belle_sip_header_www_authenticate_get_scheme(authenticate));