From 6432709b8085c32e926f0dad3cd1d349f41ca715 Mon Sep 17 00:00:00 2001 From: Rene Kita Date: Tue, 28 Dec 2021 16:13:01 +0100 Subject: [PATCH] Check for NULL before dereferencing a pointer get_auth_param() returns NULL in case of error. --- file.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/file.c b/file.c index ddc6214..964d1f4 100644 --- a/file.c +++ b/file.c @@ -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);