Commit 142ab58b authored by François Grisez's avatar François Grisez Committed by DanmeiChen

Adds a flag to GCC in order to prevent variable length arrays usage.

Reason: variable length arrays are not supported by Visual Studio's compiler.
parent 13c1841b
......@@ -171,6 +171,7 @@ else()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-builtin-requires-header" "-Wno-unused-function" "-Wno-gnu-designator" "-Wno-array-bounds")
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND STRICT_OPTIONS_C "-Werror=vla") # Forbids usage of variable length arrays since Visual Studio's compiler does not support them.
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=pragmas")
endif()
if(APPLE)
......
......@@ -75,6 +75,7 @@ belle_sip_header_proxy_authorization_t* belle_sip_auth_helper_create_proxy_autho
static void belle_sip_auth_choose_method(const char *algo, char *ask, uint8_t *out, size_t size) {
if ((algo == NULL) || (!strcmp(algo, "MD5"))) {
// By default, using MD5 when algorithm is NULL
bctbx_md5((const unsigned char *)ask, strlen(ask), out);
} else if (!strcmp(algo, "SHA-256")) {
bctbx_sha256((const unsigned char *)ask, strlen(ask), size, out);
......@@ -99,7 +100,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[length_byte];
uint8_t out[32];
size_t di;
char *ask;
if (!userid) {
......@@ -137,7 +138,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[length_byte];
uint8_t out[32];
size_t di;
char *ask;
ha2[length_byte * 2] = '\0';
......@@ -164,7 +165,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[length_byte];
uint8_t out[32];
size_t di;
char *ask;
response[length_byte * 2] = '\0';
......@@ -199,7 +200,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[length_byte];
uint8_t out[32];
size_t di;
char *ask;
char nounce_count_as_string[9];
......@@ -231,18 +232,16 @@ int belle_sip_auth_helper_compute_response_qop_auth(const char* ha1
int belle_sip_auth_helper_fill_authorization(belle_sip_header_authorization_t* authorization
,const char* method
,const char* ha1) {
size_t size;
const char *algo = belle_sip_header_authorization_get_algorithm(authorization);
size = belle_sip_auth_define_size(algo);
size_t size = belle_sip_auth_define_size(algo);
if (!size) {
belle_sip_error("Algorithm [%s] is not correct ", algo);
return -1;
}
}
int auth_mode=0;
char* uri;
char ha2[size];
char response[size];
char ha2[65];
char response[65];
char cnonce[BELLE_SIP_CNONCE_LENGTH + 1];
response[size-1]=ha2[size-1]='\0';
......
......@@ -120,7 +120,7 @@ static void compute_response(const char* username
,char* response
,size_t size
,const char* algo) {
char ha1[size],ha2[size];
char ha1[65],ha2[65];
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[size],ha2[size];
char ha1[65],ha2[65];
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[size];
char local_resp[65];
if (qop && strcmp(qop, "auth") == 0) {
compute_response_auth_qop(belle_sip_header_authorization_get_username(authorization)
, belle_sip_header_authorization_get_realm(authorization)
......@@ -217,7 +217,7 @@ static void server_process_request_event(void *obj, const belle_sip_request_even
, belle_sip_header_authorization_get_qop(authorization)
, belle_sip_request_get_method(req)
, auth_uri = belle_sip_uri_to_string(belle_sip_header_authorization_get_uri(authorization))
, local_resp
, local_resp
, size
, algo);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment