Fossil SCM
checkin/22ed60a53b0acaae929ef374e5d03e18d9d6562c8cb4ccee809a14218399afd3
Endless loop on a multipart header line
tokenize_line() in src/cgi.c splits the header lines of each part of
multipart/form-data. It did not move past a double quote that was the last
byte of a line, so its loop never ended. Any POST of that type, to a page that
reads its parameters, before any login check, held a process at full CPU: for
ever under fossil http and CGI, and until the 600-second limit under
fossil server.
The fix steps over the quote.
The review proved that each pass now moves forward. Over every string of up
to nine bytes made from the characters that matter, the old code looped on
43,946 and the new code on none, and wherever the old code finished both give
the same tokens. Tested with ASan and UBSan on macOS; the test in
test/cgi.test, which will come with the test-suite work, runs the request
with a time limit. Not run on Linux or Windows.