Package: micro-httpd
Version: 20140814-2.1+b2
Severity: normal
Tags: patch
X-Debbugs-Cc: report...@duvert.net

Dear Maintainer,

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

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.

Thanks.

-- System Information:
Debian Release: bookworm/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: arm64 (aarch64)

Kernel: Linux 6.0.0-6-arm64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_CRAP
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages micro-httpd depends on:
ii  libc6               2.36-7
ii  netcat-traditional  1.10-47
ii  systemd-sysv        252.4-1

micro-httpd recommends no packages.

Versions of packages micro-httpd suggests:
pn  micro-proxy  <none>

-- no debconf information

Reply via email to