Prerequisites
Description
Debug output fills the console with garbage, if upload_data is no terminated string, like this:
Writing content: {"login":{"pass":"config","user":"admin"}}��������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������
�������������������������������
Steps to Reproduce
- Configure libhttpserver with
--enable-debug
- Build libhttpserver
- In your app source create and hook up a resource
- Implement the
render_POST method
- Run the app in foreground
- Send POST data to it, e.g. with curl:
curl -v -H "Content-Type: application/json" -d '{"login":{"pass":"admin","user":"admin"}}' http://localhost:8888/api/v1/control/system/login
- Watch app output
Expected behavior: Consider upload_data_size and print only up to that length
Actual behavior: Blindly print until terminating null byte, possibly resulting in segfault
Reproduces how often: always with my application, not sure with other applications
Versions
- OS version: Debian GNU/Linux 10 (buster)
- libhttpserver version: 0.18.2-22-g263f2bd (current master)
- libmicrohttpd version: 0.9.62-1 (debian package)
Additional Information
The const char *upload_data is a parameter of a libmicrohttpd callback function, type MHD_AccessHandlerCallback. When reading libmicrohttpd API doc I get no clue that string might be unterminated. Maybe raise issue over there?
Prerequisites
Description
Debug output fills the console with garbage, if
upload_datais no terminated string, like this:Steps to Reproduce
--enable-debugrender_POSTmethodcurl -v -H "Content-Type: application/json" -d '{"login":{"pass":"admin","user":"admin"}}' http://localhost:8888/api/v1/control/system/loginExpected behavior: Consider
upload_data_sizeand print only up to that lengthActual behavior: Blindly print until terminating null byte, possibly resulting in segfault
Reproduces how often: always with my application, not sure with other applications
Versions
Additional Information
The
const char *upload_datais a parameter of a libmicrohttpd callback function, type MHD_AccessHandlerCallback. When reading libmicrohttpd API doc I get no clue that string might be unterminated. Maybe raise issue over there?