]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core, mod_sofia] add some extra checks when creating the digest. 1750/head
authorDragos Oancea <dragos@signalwire.com>
Mon, 8 Aug 2022 15:56:09 +0000 (18:56 +0300)
committerDragos Oancea <dragos@signalwire.com>
Mon, 8 Aug 2022 15:56:09 +0000 (18:56 +0300)
src/mod/endpoints/mod_sofia/sofia_reg.c
src/switch_utils.c

index a07d47b7586113961062f65e0bda4dddcc22b892..42c792c08b44249900787525d35529aa34002985 100644 (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 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,
index d869ddfda4a3f3b63001779ac4e0316ea6508f26..1a9341148974cd508f2bbd833470bdd00dfb3dc5 100644 (file)
@@ -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;
                }
        }