You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix std::terminate when uri_log receives null uri (#371) (#372)
* Fix std::terminate when uri_log receives null uri pointer
libmicrohttpd may invoke MHD_OPTION_URI_LOG_CALLBACK with a null uri
pointer before the request line is parsed - for example on port scans,
TLS clients hitting a plain HTTP port, or half-open connections. The
previous code assigned the raw pointer directly into a std::string,
which throws std::logic_error("basic_string::_M_construct null not
valid"). Because the throw originates inside an MHD C callback with
no enclosing handler, std::terminate() was called and the process
aborted under load.
Treat a null uri as an empty string so the assignment is well-defined.
An empty URI fails to match any registered resource and surfaces as a
404, which is the correct graceful behaviour.
Resolves#371.
* ci(codeql): bump bundled libmicrohttpd to 1.0.3
The CodeQL workflow was still pulling libmicrohttpd-0.9.64 from S3,
which is below the project's stated minimum of 1.0.0 and is no longer
served by the bucket - the install step was failing with "gzip:
stdin: not in gzip format" because curl received a 243-byte error
response instead of the tarball. Bump to 1.0.3 from the same S3
location so CodeQL can build the project again.
* ci: bump bundled libmicrohttpd to 1.0.3 in release and verify-build
Aligns release.yml and verify-build.yml with codeql-analysis.yml so all
workflows pull the same libmicrohttpd-1.0.3.tar.gz from S3. This also
brings CI in line with the project's documented minimum of >= 1.0.0
(0.9.77 was below that threshold). Cache keys include the new version
so existing 0.9.77 entries are not reused.
* test: add unit test for uri_log null/empty/valid uri handling
Adds test/unit/uri_log_test.cpp to lock in the fix for issue #371. The
test calls uri_log() directly (re-declaring the symbol since it has no
public header) and verifies three cases:
- null uri does not throw and yields an empty complete_uri
- valid uri is stored verbatim
- empty uri is stored verbatim
The first case is the regression check: against the unfixed code,
running the test crashes the process (SIGSEGV from dereferencing the
null pointer inside std::string's assignment operator on libstdc++ 13;
on the older libstdc++ 10 from the bug report it threw std::logic_error
and aborted via std::terminate). With the fix in place, all three sub-
tests pass cleanly.
The new test target needs an explicit -lmicrohttpd in its link line
because it instantiates ~modded_request() directly, which references
MHD_destroy_post_processor; the default LDADD only pulls libmicrohttpd
in transitively via libhttpserver.la, and modern ld enforces
--no-copy-dt-needed-entries.
* test(uri_log): satisfy cpplint build/include_subdir for httpserver.hpp
cpplint flags bare "httpserver.hpp" with build/include_subdir [4].
Match the convention used by every other test file in the repo and
prefix the include with "./" so cpplint considers the directory
explicit.
0 commit comments