File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,12 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
167167 size = 0 ;
168168 b = c -> buffer ;
169169
170+ if (mr -> request_line .len == 0 ) {
171+ /* return empty string on invalid request */
172+ lua_pushlstring (L , "" , 0 );
173+ return 1 ;
174+ }
175+
170176 if (mr -> request_line .data [mr -> request_line .len ] == CR ) {
171177 line_break_len = 2 ;
172178
Original file line number Diff line number Diff line change @@ -1017,3 +1017,36 @@ client sent invalid header line: "\x20..." while reading client request headers
10171017[error]
10181018--- skip_nginx
101910193: < 1.21.1
1020+
1021+
1022+
1023+ === TEST 35: bugfix: invalid http request
1024+ --- log_level: error
1025+ --- http_config
1026+ lua_package_path "../lua-resty-core/lib/?.lua;;";
1027+ --- config
1028+ location /t {
1029+ content_by_lua_block {
1030+ local sock = ngx.socket.tcp()
1031+ local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_SERVER_PORT)
1032+ if not ok then
1033+ ngx.log(ngx.ERR, "failed to connect to memc: ", err)
1034+ return
1035+ end
1036+ sock:send("\n")
1037+ sock:close()
1038+
1039+ ngx.say("OK")
1040+ }
1041+ }
1042+
1043+ log_by_lua_block {
1044+ local h = ngx.req.raw_header()
1045+ }
1046+
1047+ --- request
1048+ GET /t
1049+ --- response_body
1050+ OK
1051+ --- no_error_log
1052+ [error]
You can’t perform that action at this time.
0 commit comments