View Issue Details

IDProjectCategoryView StatusLast Update
0001594libmicrohttpdotherpublic2010-09-10 13:32
Reporterd4de Assigned ToChristian Grothoff Due Date
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.0 
Summary0001594: https_fileserver_example.c fails to send any file content and always responds with 404
DescriptionThe example was checking the existence of the file before actually opening it and reading its contents into memory, but the erroneous line below shows that it passes the `url' as a pointer to a string like "/file.html", so when stat looks up this file for other information, it exists with ENOENT, and effectively results in 404 response sent back to the client.

- if ( (0 == stat (url, &buf)) &&

The fix for this is very simple, instead we just pass the pointer address for the second character on wards, so now it is looking at the current directory instead of `/'.

+ if ( (0 == stat (&url[1], &buf)) &&
Additional InformationPlease see attached a patch for this bug.
TagsNo tags attached.
Attached Files
https_fileserver_example.c.patch (413 bytes)   
--- libmicrohttpd/src/examples/https_fileserver_example.c.orig	2010-07-24 15:24:50.000000000 +0000
+++ libmicrohttpd/src/examples/https_fileserver_example.c	2010-07-29 20:32:16.000000000 +0000
@@ -138,5 +138,5 @@
   *ptr = NULL;                  /* reset when done */
 
-  if ( (0 == stat (url, &buf)) &&
+  if ( (0 == stat (&url[1], &buf)) &&
        (S_ISREG (buf.st_mode)) )
     file = fopen (&url[1], "rb");

Activities

Christian Grothoff

2010-07-30 04:53

manager   ~0004094

Fixed in SVN 12401.

Issue History

Date ModifiedUsernameFieldChange
2010-07-30 04:17d4deNew Issue
2010-07-30 04:17d4deFile Added: https_fileserver_example.c.patch
2010-07-30 04:53Christian GrothoffNote Added: 0004094
2010-07-30 04:53Christian GrothoffStatusnew => resolved
2010-07-30 04:53Christian GrothoffResolutionopen => fixed
2010-07-30 04:53Christian GrothoffAssigned To => Christian Grothoff
2010-09-10 13:32Christian GrothoffStatusresolved => closed