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

Fix malformed headers #136

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Conversation

steve-chavez
Copy link
Member

@steve-chavez steve-chavez commented Aug 7, 2024

When having a malformed header such as:

$ curl localhost:8080/pathological?malformed-header=header-injection -i
HTTP/1.1 200 OK
Server: nginx/1.26.0

HeaderInjection
Injected-Header: This header contains an injection

The background worker crashes.

To prove the above, we use https://github.com/steve-chavez/ngx_pathological.

@steve-chavez
Copy link
Member Author

steve-chavez commented Aug 7, 2024

Tempted to use this newish (2022) curl feature for parsing the headers: https://curl.se/libcurl/c/curl_easy_nextheader.html (announcement). It's pretty convenient.

It's available from curl 7.83, I believe now that we have Nix on prod it should be doable to get this version.

Note: We need to document this requirement on the README.

We might solve this as well #115

@steve-chavez

This comment was marked as outdated.

- Now libcurl >= 7.83 is a requirement
- Tests are changed to fit new libcurl behavior
@steve-chavez steve-chavez marked this pull request as ready for review August 8, 2024 06:27
worker.bgw_main_arg = (Datum) 0;
worker.bgw_notify_pid = 0;
RegisterBackgroundWorker(&worker);
RegisterBackgroundWorker(&(BackgroundWorker){

Choose a reason for hiding this comment

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

IMO previous state of pg_init() was completely ok and also was easier to read.

Copy link
Member Author

@steve-chavez steve-chavez Aug 8, 2024

Choose a reason for hiding this comment

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

The new way using C99 designated initializer requires fewer LOC and avoids the need to memset to 0. Readability is highly subjective but fewer LOCs in this case is a win IMO.

@steve-chavez steve-chavez merged commit c2ba87b into supabase:master Aug 9, 2024
5 checks passed
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.

3 participants