aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/digestauth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/digestauth.c')
-rw-r--r--src/microhttpd/digestauth.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 8e38dc41..851eaa3f 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -822,6 +822,7 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection,
822 signal_stale 822 signal_stale
823 ? ",stale=\"true\"" 823 ? ",stale=\"true\""
824 : ""); 824 : "");
825 if (hlen > 0)
825 { 826 {
826 char *header; 827 char *header;
827 828
@@ -835,7 +836,7 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection,
835 return MHD_NO; 836 return MHD_NO;
836 } 837 }
837 838
838 MHD_snprintf_(header, 839 if (MHD_snprintf_(header,
839 hlen + 1, 840 hlen + 1,
840 "Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"%s", 841 "Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"%s",
841 realm, 842 realm,
@@ -843,16 +844,28 @@ MHD_queue_auth_fail_response (struct MHD_Connection *connection,
843 opaque, 844 opaque,
844 signal_stale 845 signal_stale
845 ? ",stale=\"true\"" 846 ? ",stale=\"true\""
846 : ""); 847 : "") == hlen)
847 ret = MHD_add_response_header(response, 848 ret = MHD_add_response_header(response,
848 MHD_HTTP_HEADER_WWW_AUTHENTICATE, 849 MHD_HTTP_HEADER_WWW_AUTHENTICATE,
849 header); 850 header);
851 else
852 ret = MHD_NO;
850 free(header); 853 free(header);
851 } 854 }
855 else
856 ret = MHD_NO;
857
852 if (MHD_YES == ret) 858 if (MHD_YES == ret)
853 ret = MHD_queue_response(connection, 859 ret = MHD_queue_response(connection,
854 MHD_HTTP_UNAUTHORIZED, 860 MHD_HTTP_UNAUTHORIZED,
855 response); 861 response);
862 else
863 {
864#ifdef HAVE_MESSAGES
865 MHD_DLOG (connection->daemon,
866 "Failed to add Digest auth header\n");
867#endif /* HAVE_MESSAGES */
868 }
856 return ret; 869 return ret;
857} 870}
858 871