commit c836cdfadb29dde5f7afee662a27e9d691bb9ba0 from: Omar Polo date: Mon Mar 29 09:42:06 2021 UTC handle CGI scripts that replies with the maximum header length allowed the 1024 bytes limits is for the META only, not for the whole response. That means that the maximum size for the header line is 1029! commit - 071dce449d98389d76d1bfaef31363664d0dfdda commit + c836cdfadb29dde5f7afee662a27e9d691bb9ba0 blob - 43300e22b39935eb2de236c078b58672340c1379 blob + 3e8e2c60828faca2c525dec050f8c0f815735860 --- ChangeLog +++ ChangeLog @@ -1,3 +1,7 @@ +2021-03-27 Omar Polo + + * gmid.h (struct client): correctly handle CGI scripts that replies with the maximum header length allowed + 2021-03-20 Omar Polo * 1.6 tagged blob - 7e9bba0ea360599496bdc6cd5ca3672e11dcc6ec blob + 8188bf993352830d3837e94e7e95824635e4a5f8 --- gmid.h +++ gmid.h @@ -180,8 +180,11 @@ struct client { const char *meta; int fd, pfd; DIR *dir; - char sbuf[1024]; + + /* big enough to store STATUS + SPACE + META + CRLF */ + char sbuf[1029]; ssize_t len, off; + struct sockaddr_storage addr; struct vhost *host; /* host they're talking to */ }; blob - 317a4607a521c3cd2bc2630857da78c553ad5159 blob + b485d6498603cf02baede84cf3178ae0c7b112af --- regress/Makefile +++ regress/Makefile @@ -68,6 +68,7 @@ testdata: fill-file printf "# hello world\n" > testdata/index.gmi ./sha testdata/index.gmi testdata/index.gmi.sha cp hello slow err invalid serve-bigfile env testdata/ + cp max-length-reply testdata mkdir testdata/dir cp hello testdata/dir cp testdata/index.gmi testdata/dir/foo.gmi blob - /dev/null blob + 0311158a4148b35aef0ee406f21d96a16b4a68d5 (mode 755) --- /dev/null +++ regress/max-length-reply @@ -0,0 +1,3 @@ +#!/bin/sh + +printf '20 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\r\n' blob - 80bf32c646b85696643ce2eb61ad024fb5edf538 blob + d24ac08e71e386d883506b38dcb1d58d510c0a4f --- regress/runtime +++ regress/runtime @@ -183,6 +183,9 @@ echo OK GET /err with cgi eq "$(raw /invalid | wc -c | xargs)" 2048 "Unexpected body for /invalid" echo OK GET /invalid with cgi +eq "$(raw /max-length-reply | wc -c | xargs)" 1029 "Unexpected header for /max-length-reply" +echo OK GET /max-length-reply with cgi + # try a big file eq "$(head /serve-bigfile)" "20 application/octet-stream" "Unexpected head for /serve-bigfile" get /bigfile > bigfile