Skip to content

Commit

Permalink
uac_auth(): Fix corner-case with missing "algorithm=" in 401
Browse files Browse the repository at this point in the history
Make sure to convert ALG_UNSPEC to ALG_MD5 before doing the bitmask
conversion, as otherwise the matching will fail!

Partial revert of commit 977ce90.
  • Loading branch information
liviuchircu committed Oct 3, 2024
1 parent c874006 commit 7fe1fe4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/digest_auth/digest_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ int dauth_algorithm_check(const struct authenticate_body *auth,
if (!digest_algorithm_available(auth->algorithm))
return (0);
damp = (const struct dauth_algorithm_match *)mdp->argp;
return (ALG2ALGFLG(auth->algorithm) & damp->algmask);
return (ALG2ALGFLG(auth->algorithm==ALG_UNSPEC ? ALG_MD5:auth->algorithm)
& damp->algmask);
}

int dauth_fixup_algorithms(void** param)
Expand Down
2 changes: 1 addition & 1 deletion modules/uac/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ int uac_auth( struct sip_msg *msg, unsigned algmask)
}

if (auth == NULL) {
LM_ERR("Unable to extract authentication info\n");
LM_ERR("Unable to extract a compatible authentication challenge\n");
goto error;
}

Expand Down
3 changes: 2 additions & 1 deletion modules/uac/uac.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ static int w_replace_to(struct sip_msg* msg, str *dsp, str *uri)

static int w_uac_auth(struct sip_msg* msg, intptr_t _alg)
{
return (uac_auth(msg, !_alg ? 0U:*(unsigned *)_alg)==0)?1:-1;

return (uac_auth(msg, _alg)==0)?1:-1;
}


Expand Down

0 comments on commit 7fe1fe4

Please sign in to comment.