commit 772d6dc483c1c71e8fba223aca7d2c532a3b34746c218e2f3011f2c92dd1c58d from: Omar Polo date: Thu Jul 31 09:42:34 2025 UTC fix math in fcgi_send_response We can't hit actually hit this because our buffers are way smaller than FCGI_CONTENT_SIZE (65536) but if we were, we'd end up sending wrong fastcgi packets. found with / ok stsp@ commit - 6ce74ad156746308dd5ca0da429928da06e1e2e84417bc35461c92e18023a12d commit + 772d6dc483c1c71e8fba223aca7d2c532a3b34746c218e2f3011f2c92dd1c58d blob - d6f02590c5a06fdb906d58bc8069d02985b9dd4cbc791d7545f4d361b7c5b048 blob + 9d4719bf91324b24038709523cb4dd8679c6811c0f12b864e14c7f26ecbc424e --- gotwebd/fcgi.c +++ gotwebd/fcgi.c @@ -449,21 +449,23 @@ int fcgi_send_response(struct request *c, int type, const void *data, size_t len) { + size_t avail; + if (c->client_status == CLIENT_DISCONNECT) return -1; - while (len > FCGI_CONTENT_SIZE) { - if (send_response(c, type, data, len) == -1) + while (len > 0) { + avail = len; + if (avail > FCGI_CONTENT_SIZE) + avail = FCGI_CONTENT_SIZE; + + if (send_response(c, type, data, avail) == -1) return -1; - - data += FCGI_CONTENT_SIZE; - len -= FCGI_CONTENT_SIZE; + data += avail; + len -= avail; } - if (len == 0) - return 0; - - return send_response(c, type, data, len); + return 0; } int