commit 40e36ce5301442ff9172f57a80b91e1ca8bfd426 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 - 3ced9adc82b7b84e9901e32013122f99ff703070 commit + 40e36ce5301442ff9172f57a80b91e1ca8bfd426 blob - df49986c584e5a1f45a0def6d23843ddbdc8ef91 blob + 98b144aa064f722540e70cb344a42e3e59abf96e --- 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) - return -1; + while (len > 0) { + avail = len; + if (avail > FCGI_CONTENT_SIZE) + avail = FCGI_CONTENT_SIZE; - data += FCGI_CONTENT_SIZE; - len -= FCGI_CONTENT_SIZE; + if (send_response(c, type, data, avail) == -1) + return -1; + data += avail; + len -= avail; } - if (len == 0) - return 0; - - return send_response(c, type, data, len); + return 0; } int