View Issue Details

IDProjectCategoryView StatusLast Update
0001651libmicrohttpddigest authentication (HTTP)public2011-02-15 11:19
Reportertimn Assigned ToChristian Grothoff Due Date
PrioritynormalSeveritymajorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.4 
Summary0001651: MHD_queue_basic_auth_fail_response condition always false
Descriptionsnprintf() returns "the number of characters printed (not including the trailing '\0' used to end output to strings)" (from man snprintf). But hlen contains the number of bytes plus the null termination byte. Therefore this condition can never become true, and hence basic authentication cannot work.

The attached patch fixes this problem.
TagsNo tags attached.
Attached Files
libmicrohttpd-0.9.5-fix-basic-auth.patch (691 bytes)   
diff -urN libmicrohttpd-0.9.5/src/daemon/digestauth.c libmicrohttpd-0.9.5.fix-basic-auth/src/daemon/digestauth.c
--- libmicrohttpd-0.9.5/src/daemon/digestauth.c	2011-01-10 14:06:56.000000000 +0100
+++ libmicrohttpd-0.9.5.fix-basic-auth/src/daemon/digestauth.c	2011-01-24 21:24:52.204949568 +0100
@@ -723,12 +723,12 @@
 				   struct MHD_Response *response) 
 {
   int ret;
-  size_t hlen = strlen(realm) + strlen("Basic realm=\"\"") + 1;
-  char header[hlen];
+  size_t hlen = strlen(realm) + strlen("Basic realm=\"\"");
+  char header[hlen + 1];
 
   if (hlen !=
       snprintf(header, 
-	       sizeof(header), 
+	       hlen + 1, 
 	       "Basic realm=\"%s\"", 
 	       realm))
     {

Activities

timn

2011-01-24 23:29

reporter   ~0004235

Version is actually 0.9.5 and reproducibility should be "always".

Christian Grothoff

2011-01-27 09:50

manager   ~0004237

Fixed in SVN 14276 (by removing the clearly too trivial assertion, which is simply code bloat anyway).

Issue History

Date ModifiedUsernameFieldChange
2011-01-24 23:28timnNew Issue
2011-01-24 23:28timnFile Added: libmicrohttpd-0.9.5-fix-basic-auth.patch
2011-01-24 23:29timnNote Added: 0004235
2011-01-27 09:50Christian GrothoffNote Added: 0004237
2011-01-27 09:50Christian GrothoffStatusnew => resolved
2011-01-27 09:50Christian GrothoffResolutionopen => fixed
2011-01-27 09:50Christian GrothoffAssigned To => Christian Grothoff
2011-02-15 11:19Christian GrothoffStatusresolved => closed
2013-05-06 10:52Christian GrothoffCategorydigest authentication => digest authentication (HTTP)