From e2c3e740ec69f427e1a3e9bad263e461627e7046 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 13 Jun 2018 10:47:24 +0200 Subject: [PATCH] make sure algorithm are compared case unsensitively --- coreapi/authentication.c | 6 +++--- coreapi/callbacks.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/coreapi/authentication.c b/coreapi/authentication.c index 5ae67f4d2..2832b8c46 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -61,7 +61,7 @@ LinphoneAuthInfo *linphone_auth_info_new_for_algorithm(const char *username, con if (!algorithm) obj->algorithm = ms_strdup("MD5"); - if(algorithm && strcmp(algorithm, "MD5") && strcmp(algorithm, "SHA-256")){ + if(algorithm && strcasecmp(algorithm, "MD5") && strcasecmp(algorithm, "SHA-256")){ ms_error("Given algorithm %s is not correct.", algorithm); return NULL; } @@ -258,12 +258,12 @@ void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, in } if (!obj->ha1 && obj->realm && obj->passwd && (obj->username || obj->userid) && store_ha1_passwd) { /* Default algorithm is MD5 if it's NULL */ - if((obj->algorithm==NULL)||(!(strcmp(obj->algorithm, "MD5")))){ + if((obj->algorithm==NULL)||(!(strcasecmp(obj->algorithm, "MD5")))){ obj->ha1 = reinterpret_cast(ms_malloc(33)); sal_auth_compute_ha1(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1); } /* If algorithm is SHA-256, calcul ha1 by sha256*/ - if((obj->algorithm)&&(!(strcmp(obj->algorithm, "SHA-256")))){ + if((obj->algorithm)&&(!(strcasecmp(obj->algorithm, "SHA-256")))){ obj->ha1 = reinterpret_cast(ms_malloc(65)); sal_auth_compute_ha1_for_algorithm(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1,65, obj->algorithm); } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index eaa118ae1..87bc3ab80 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -515,11 +515,11 @@ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) { * exit. The default algorithm is MD5 if it's NULL. */ if (sai->algorithm && ai->algorithm) { - if (strcmp(ai->algorithm, sai->algorithm)) + if (strcasecmp(ai->algorithm, sai->algorithm)) return TRUE; } else if ( - (ai->algorithm && strcmp(ai->algorithm, "MD5")) || - (sai->algorithm && strcmp(sai->algorithm, "MD5")) + (ai->algorithm && strcasecmp(ai->algorithm, "MD5")) || + (sai->algorithm && strcasecmp(sai->algorithm, "MD5")) ) return TRUE;