-
Notifications
You must be signed in to change notification settings - Fork 192
Description
Prerequisites
- Put an X between the brackets on this line if you have checked that your issue isn't already filed: https://github.com/search?l=&q=repo%3Aetr%2Flibhttpserver&type=Issues
Description
When creating an object of class httpserver::file_response
with a filename
not related to an actually existing file, the behavior of the application is more or less unpredictable depending on which version of libmicrohttpd is used. We saw HTTP responses with status 200 and an empty data part, but the app might as well segfault.
Steps to Reproduce
- Create an instance of class
httpserver::file_response
with afilename
pointing to a non existent file - Use that object as a response for an actual request
Expected behavior: webserver returns a sensible HTTP status code like 500 (Internal Server Error) or better 404 (Not Found).
Actual behavior: webserver crashes (segfault), does not answer, or even returns code passed to constructor of file_response
Reproduces how often: always
Versions
- OS version
- Debian GNU/Linux 10 (buster)
- custom built embedded firmware
- libhttpserver version: master, self compiled
- libmicrohttpd version: multiple self compiled from v0.9.53 up to v0.9.73
If you have problems during build: build is fine
Additional Information
What happens is httpserver::file_response::get_raw_response()
might return a nullptr
which is then passed on to http_response::decorate_response()
which itself calls some libmicrohttpd functions like MHD_add_response_header()
or MHD_add_response_footer()
which might or might not crash depending on version.
Will show a unit test reproducing this.