On Thu, 05 Jan 2023 13:08:45 +0000 Vincent Duvert <report...@duvert.net> wrote:
> When micro-httpd tries to list the contents of a directory but fails (if the
> directory is not readable, for instance), an invalid HTTP response is 
> returned:
>
> > GET /.well-known/ HTTP/1.0
> >
> < scandir: Permission denied
> < HTTP/1.0 200 Ok
> < Server: micro_httpd
> < ...
>
> Looking at the source code, micro-httpd calls perror( "scandir" ); after
> sending the HTTP headers, but due to standard output buffering, the error
> message ends up being sent first.
>
> An easy fix is to change micro-httpd@.service so micro-httpd's standard error
> is sent to the logs instead of the connection socket:
>
> [Service]
> StandardError=journal

I can implement this in an NMU.

> A more complete fix would be to move the call to scandir (line 119) just 
> before
> the call to send_headers(200, ...) (line 108), and to call send_error if 
> scandir
> fails.

This one needs to be sent to upstream.

If you do so, please take the opportunity to ask him to consider using
e.g. micro-httpd_2024-04-29.tar.xz as his tarball name. Tracking dates
in ISO format is a lot easier to implement than e.g. 14Aug2014.

Martin-Éric

Reply via email to