jart / cosmopolitan

build-once run-anywhere c library
ISC License
18.43k stars 637 forks source link

Bug: [redbean] Fetch() HTTP client ParseHttpMessage error on big headers #1315

Closed elitepleb closed 1 month ago

elitepleb commented 1 month ago

What happened?

Another Fetch() error that errors out on an input that is one longer than the previous.
In this case, 1286 writes Good!, 1287 writes Bad! and triggers an early exit in ParseHttpMessage This broke an internal tool when updating to the 3.0 release.
As requests after authentication would fail, but only in specific cases.

.init.lua test case

function OnHttpRequest()
        if GetPath() == '/headers' then
                SetHeader('padding', string.rep('a',1287) )
                Write('Hello world!')
        else
                result = Fetch('http://127.0.0.1:8080/headers')
                if result then
                        Write('Good!')
                else
                        Write('Bad!')
                end
        end
end

Version

redbean releases after z0.0.43

What operating system are you seeing the problem on?

Linux