View Issue Details

IDProjectCategoryView StatusLast Update
0001594libmicrohttpdotherpublic2010-09-10 15:32
Reporterd4de Assigned ToChristian Grothoff  
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 06:53

manager   ~0004094

Fixed in SVN 12401.

Issue History

Date Modified Username Field Change
2010-07-30 06:17 d4de New Issue
2010-07-30 06:17 d4de File Added: https_fileserver_example.c.patch
2010-07-30 06:53 Christian Grothoff Note Added: 0004094
2010-07-30 06:53 Christian Grothoff Status new => resolved
2010-07-30 06:53 Christian Grothoff Resolution open => fixed
2010-07-30 06:53 Christian Grothoff Assigned To => Christian Grothoff
2010-09-10 15:32 Christian Grothoff Status resolved => closed