forked from Mirrors/freeswitch
[core, mod_sofia] add some extra checks when creating the digest.
This commit is contained in:
parent
29afa27cdd
commit
c9def5990e
|
@ -2943,23 +2943,24 @@ sofia_auth_algs_t sofia_alg_str2id(char *algorithm, switch_bool_t permissive)
|
|||
|
||||
switch_status_t sofia_make_digest(sofia_auth_algs_t use_alg, char **digest, const void *input, unsigned int *outputlen)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
switch (use_alg)
|
||||
{
|
||||
case ALG_MD5:
|
||||
switch_digest_string("md5", digest, input, strlen((char *)input), outputlen);
|
||||
status = switch_digest_string("md5", digest, input, strlen((char *)input), outputlen);
|
||||
break;
|
||||
case ALG_SHA256:
|
||||
switch_digest_string("sha256", digest, input, strlen((char *)input), outputlen);
|
||||
status = switch_digest_string("sha256", digest, input, strlen((char *)input), outputlen);
|
||||
break;
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10101000L
|
||||
case ALG_SHA512:
|
||||
switch_digest_string("sha512-256", digest, input, strlen((char *)input), outputlen);
|
||||
status = switch_digest_string("sha512-256", digest, input, strlen((char *)input), outputlen);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
|
||||
auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
|
||||
|
|
|
@ -4640,6 +4640,10 @@ SWITCH_DECLARE(switch_status_t) switch_digest_string(const char *digest_name, ch
|
|||
}
|
||||
|
||||
(*digest_str)[i] = '\0';
|
||||
} else {
|
||||
switch_safe_free(digest);
|
||||
*outputlen = 0;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue