Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod_proxy_fcgi: Support Dynamic Buffering for Large FastCGI Headers #522

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

arturobernalg
Copy link
Member

This pull request implements a dynamic header buffer in mod_proxy_fcgi to resolve Bug 64919. Previously, mod_proxy_fcgi used a fixed 8192-byte buffer to parse FastCGI headers, which caused failures when PHP-FPM (or similar backends) generated headers exceeding that size. With this patch, a dynamically resizable buffer is used so that arbitrarily large headers are handled gracefully.

@@ -593,6 +594,72 @@ static int handle_headers(request_rec *r, int *state,
return 0;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be added to the varbuf API in server/util.c or else the existing ap_varbuf_* should be used, IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sound reasonable move it to server/util.c

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Please @notroj do another pass

@@ -640,6 +707,10 @@ static apr_status_t dispatch(proxy_conn_rec *conn, proxy_dir_conf *conf,
ib = apr_brigade_create(r->pool, c->bucket_alloc);
ob = apr_brigade_create(r->pool, c->bucket_alloc);

/* Create our dynamic header buffer for large headers */
ap_varbuf *header_vb = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaration should be at the top of the function, this is causing the CI failures.

Copy link
Member Author

@arturobernalg arturobernalg Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it

@arturobernalg arturobernalg force-pushed the 64919-mod_proxy_fcgi-long-header branch from 60c3136 to 6f2a011 Compare March 11, 2025 08:31
This patch fixes Bug 64919 by replacing the fixed 8192‐byte header buffer with a
dynamically resizable buffer that can handle arbitrarily long headers. It also adds
a trimming step to remove any leading whitespace from the header data before
parsing, ensuring that FastCGI responses are correctly interpreted.
@arturobernalg arturobernalg force-pushed the 64919-mod_proxy_fcgi-long-header branch from d209278 to 0eec747 Compare March 11, 2025 15:24
@arturobernalg arturobernalg requested a review from notroj March 11, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants