diff --git a/include/belle-sip/auth-helper.h b/include/belle-sip/auth-helper.h index 937a3e6a8b336cd28c2c48aa790ef8f01e737e78..b6be8641fa831330d5435a6aa4587b4071211ccd 100644 --- a/include/belle-sip/auth-helper.h +++ b/include/belle-sip/auth-helper.h @@ -22,6 +22,9 @@ #include "belle-sip/defs.h" #include "belle-sip/belle-sip.h" +#define MAX_LENGTH_BYTE 32 +#define MAX_RESPONSE_SIZE 65 + BELLE_SIP_BEGIN_DECLS /** diff --git a/src/auth_helper.c b/src/auth_helper.c index 1b7946c56811d2c00288b28db0bb2875eb891943..7c5ea5f782c500b0d186a7c65cd6e4fd12411f9c 100644 --- a/src/auth_helper.c +++ b/src/auth_helper.c @@ -22,7 +22,6 @@ #include #include "bctoolbox/crypto.h" - #ifndef BELLE_SIP_CNONCE_LENGTH #define BELLE_SIP_CNONCE_LENGTH 16 #endif @@ -100,7 +99,7 @@ int belle_sip_auth_helper_compute_ha1_for_algorithm(const char *userid, const ch return -1; } size_t length_byte = (size - 1) / 2; - uint8_t out[32]; + uint8_t out[MAX_LENGTH_BYTE]; size_t di; char *ask; if (!userid) { @@ -138,7 +137,7 @@ int belle_sip_auth_helper_compute_ha2_for_algorithm(const char *method, const ch return -1; } size_t length_byte = (size - 1) / 2; - uint8_t out[32]; + uint8_t out[MAX_LENGTH_BYTE]; size_t di; char *ask; ha2[length_byte * 2] = '\0'; @@ -165,7 +164,7 @@ int belle_sip_auth_helper_compute_response_for_algorithm(const char *ha1, const return -1; } size_t length_byte = (size - 1) / 2; - uint8_t out[32]; + uint8_t out[MAX_LENGTH_BYTE]; size_t di; char *ask; response[length_byte * 2] = '\0'; @@ -200,7 +199,7 @@ int belle_sip_auth_helper_compute_response_qop_auth_for_algorithm(const char* ha return -1; } size_t length_byte = (size - 1) / 2; - uint8_t out[32]; + uint8_t out[MAX_LENGTH_BYTE]; size_t di; char *ask; char nounce_count_as_string[9]; @@ -240,8 +239,8 @@ int belle_sip_auth_helper_fill_authorization(belle_sip_header_authorization_t* a } int auth_mode=0; char* uri; - char ha2[65]; - char response[65]; + char ha2[MAX_RESPONSE_SIZE]; + char response[MAX_RESPONSE_SIZE]; char cnonce[BELLE_SIP_CNONCE_LENGTH + 1]; response[size-1]=ha2[size-1]='\0'; diff --git a/tester/belle_sip_refresher_tester.c b/tester/belle_sip_refresher_tester.c index f094eaa643581e70c13748170922183ccf7dac58..4f90145cb2dd7d96405ae488405b0546be59ab19 100644 --- a/tester/belle_sip_refresher_tester.c +++ b/tester/belle_sip_refresher_tester.c @@ -120,7 +120,7 @@ static void compute_response(const char* username ,char* response ,size_t size ,const char* algo) { - char ha1[65],ha2[65]; + char ha1[MAX_RESPONSE_SIZE],ha2[MAX_RESPONSE_SIZE]; belle_sip_auth_helper_compute_ha1_for_algorithm(username,realm,passwd,ha1,size,algo); belle_sip_auth_helper_compute_ha2_for_algorithm(method,uri,ha2,size,algo); belle_sip_auth_helper_compute_response_for_algorithm(ha1,nonce,ha2,response,size,algo); @@ -138,7 +138,7 @@ static void compute_response_auth_qop(const char* username ,char* response ,size_t size ,const char* algo) { - char ha1[65],ha2[65]; + char ha1[MAX_RESPONSE_SIZE],ha2[MAX_RESPONSE_SIZE]; belle_sip_auth_helper_compute_ha1_for_algorithm(username,realm,passwd,ha1,size,algo); belle_sip_auth_helper_compute_ha2_for_algorithm(method,uri,ha2,size,algo); belle_sip_auth_helper_compute_response_qop_auth_for_algorithm(ha1, nonce,nonce_count, cnonce,qop,ha2,response,size,algo); @@ -206,7 +206,7 @@ static void server_process_request_event(void *obj, const belle_sip_request_even belle_sip_error("Algorithm [%s] is not correct ", algo); return; } - char local_resp[65]; + char local_resp[MAX_RESPONSE_SIZE]; if (qop && strcmp(qop, "auth") == 0) { compute_response_auth_qop(belle_sip_header_authorization_get_username(authorization) , belle_sip_header_authorization_get_realm(authorization)