Project

General

Profile

Bug #2941

failed assertion on incoming bad request when server.error-handler option is used

Added by andpr 2 months ago. Updated 2 months ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
2019-03-12
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

Hi,

I'm using mod_scgi and the server.error-handler option. If a bad http request comes in, the lighttpd server hits an assertion when preparing the headers for the scgi execution.

http-header-glue.c.1431: assertion failed: s

Initializing the con->request.http_version field in the error_handler case makes this assertion disappear.

--- lighttpd-1.4.53-org/src/connections.c    2019-01-27 10:22:20.000000000 +0100
+++ lighttpd-1.4.53-patched/src/connections.c    2019-03-12 09:54:18.663685376 +0100
@@ -1221,6 +1221,7 @@
                                 con->error_handler_saved_method = con->request.http_method;

                                 con->request.http_method = HTTP_METHOD_GET;
+                                con->request.http_version = HTTP_VERSION_1_1;
                             } else { /*(preserve behavior for server.error-handler-404)*/
                                 con->error_handler_saved_status = -con->http_status; /*(negative to flag old behavior)*/
                             }

Associated revisions

Revision 5440f04e (diff)
Added by gstrauss 2 months ago

[core] fix assertion with server.error-handler (fixes #2941)

(thx andpr)

x-ref:
"failed assertion on incoming bad request when server.error-handler option is used"
https://redmine.lighttpd.net/issues/2941

History

#1

Updated by gstrauss 2 months ago

Thanks for the patch. I think this is more generic and more correct for a wider variety of clients.

--- a/src/connections.c
+++ b/src/connections.c
@@ -1192,6 +1192,7 @@ static int connection_handle_request(server *srv, connection *con) {
                                                        } else { /*(preserve behavior for server.error-handler-404)*/
                                                                con->error_handler_saved_status = -con->http_status; /*(negative to flag old behavior)*/
                                                        }
+                                                       if (con->request.http_version == HTTP_VERSION_UNSET) con->request.http_version = HTTP_VERSION_1_0;

                                                        buffer_copy_buffer(con->request.uri, error_handler);
                                                        connection_handle_errdoc_init(con);
#2

Updated by andpr 2 months ago

Sure, you're the expert. Your patch works for me too.
Thanks for the fast feedback.

#3

Updated by gstrauss 2 months ago

  • Status changed from New to Patch Pending
  • Target version changed from 1.4.x to 1.4.54
#4

Updated by gstrauss 2 months ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Also available in: Atom