Merge pull request #1750 from dragos-oancea/ssl-err

[core, mod_sofia] add some extra checks when creating the digest.
This commit is contained in:
Andrey Volk 2022-08-08 22:56:01 +03:00 committed by GitHub
commit 5b38db4fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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 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) switch (use_alg)
{ {
case ALG_MD5: 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; break;
case ALG_SHA256: 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; break;
#if OPENSSL_VERSION_NUMBER >= 0x10101000L #if OPENSSL_VERSION_NUMBER >= 0x10101000L
case ALG_SHA512: 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; break;
#endif #endif
default: default:
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
return SWITCH_STATUS_SUCCESS; return status;
} }
auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,

View File

@ -4640,6 +4640,10 @@ SWITCH_DECLARE(switch_status_t) switch_digest_string(const char *digest_name, ch
} }
(*digest_str)[i] = '\0'; (*digest_str)[i] = '\0';
} else {
switch_safe_free(digest);
*outputlen = 0;
return SWITCH_STATUS_FALSE;
} }
} }