Check for NULL before dereferencing a pointer

get_auth_param() returns NULL in case of error.
This commit is contained in:
Rene Kita
2021-12-28 16:13:01 +01:00
parent 22d1fb47ac
commit 6432709b80
+6 -7
View File
@@ -1381,16 +1381,15 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
*/
tmp = Strnew_m_charp("Digest username=\"", uname->ptr, "\"", NULL);
Strcat_m_charp(tmp, ", realm=",
get_auth_param(ha->param, "realm")->ptr, NULL);
Strcat_m_charp(tmp, ", nonce=",
get_auth_param(ha->param, "nonce")->ptr, NULL);
if ((s = get_auth_param(ha->param, "realm")) != NULL)
Strcat_m_charp(tmp, ", realm=", s->ptr, NULL);
if ((s = get_auth_param(ha->param, "nonce")) != NULL)
Strcat_m_charp(tmp, ", nonce=", s->ptr, NULL);
Strcat_m_charp(tmp, ", uri=\"", uri->ptr, "\"", NULL);
Strcat_m_charp(tmp, ", response=\"", rd->ptr, "\"", NULL);
if (algorithm)
Strcat_m_charp(tmp, ", algorithm=",
get_auth_param(ha->param, "algorithm")->ptr, NULL);
if (algorithm && (s = get_auth_param(ha->param, "algorithm")))
Strcat_m_charp(tmp, ", algorithm=", s->ptr, NULL);
if (cnonce)
Strcat_m_charp(tmp, ", cnonce=\"", cnonce->ptr, "\"", NULL);