-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 panic in storageHandler #27446
Fix panic in storageHandler #27446
Conversation
The prefix parameter could be removed. |
@lunny Do you mean that it could be extracted from request URL? |
If it's a |
|
storageHandler() is written as a middleware but is used as an endpoint handler, and thus `next` is actually `nil`, which causes a null pointer dereference when a request URL does not match the pattern (where it calls `next.ServerHTTP()`). Example CURL command to trigger the panic: ``` curl -I "http://yourhost/gitea//avatars/a" ``` Fixes go-gitea#27409
4ac8e0f
to
3e3ae4a
Compare
OK, added it back |
If the prefix parameter is removed, |
storageHandler() is written as a middleware but is used as an endpoint handler, and thus `next` is actually `nil`, which causes a null pointer dereference when a request URL does not match the pattern (where it calls `next.ServerHTTP()`). Example CURL command to trigger the panic: ``` curl -I "http://yourhost/gitea//avatars/a" ``` Fixes go-gitea#27409 --- Note: the diff looks big but it's actually a small change - all I did was to remove the outer closure (and one level of indentation) ~and removed the HTTP method and pattern checks as they seem redundant because go-chi already does those checks~. You might want to check "Hide whitespace" when reviewing it. Alternative solution (a bit simpler): append `, misc.DummyOK` to the route declarations that utilize `storageHandler()` - this makes it return an empty response when the URL is invalid. I've tested this one and it works too. Or maybe it would be better to return a 400 error in that case (?)
storageHandler() is written as a middleware but is used as an endpoint handler, and thus `next` is actually `nil`, which causes a null pointer dereference when a request URL does not match the pattern (where it calls `next.ServerHTTP()`). Example CURL command to trigger the panic: ``` curl -I "http://yourhost/gitea//avatars/a" ``` Fixes go-gitea#27409 --- Note: the diff looks big but it's actually a small change - all I did was to remove the outer closure (and one level of indentation) ~and removed the HTTP method and pattern checks as they seem redundant because go-chi already does those checks~. You might want to check "Hide whitespace" when reviewing it. Alternative solution (a bit simpler): append `, misc.DummyOK` to the route declarations that utilize `storageHandler()` - this makes it return an empty response when the URL is invalid. I've tested this one and it works too. Or maybe it would be better to return a 400 error in that case (?)
Backport #27446 by @sryze storageHandler() is written as a middleware but is used as an endpoint handler, and thus `next` is actually `nil`, which causes a null pointer dereference when a request URL does not match the pattern (where it calls `next.ServerHTTP()`). Example CURL command to trigger the panic: ``` curl -I "http://yourhost/gitea//avatars/a" ``` Fixes #27409 --- Note: the diff looks big but it's actually a small change - all I did was to remove the outer closure (and one level of indentation) ~and removed the HTTP method and pattern checks as they seem redundant because go-chi already does those checks~. You might want to check "Hide whitespace" when reviewing it. Alternative solution (a bit simpler): append `, misc.DummyOK` to the route declarations that utilize `storageHandler()` - this makes it return an empty response when the URL is invalid. I've tested this one and it works too. Or maybe it would be better to return a 400 error in that case (?) Co-authored-by: Sergey Zolotarev <[email protected]>
Backport #27446 by @sryze storageHandler() is written as a middleware but is used as an endpoint handler, and thus `next` is actually `nil`, which causes a null pointer dereference when a request URL does not match the pattern (where it calls `next.ServerHTTP()`). Example CURL command to trigger the panic: ``` curl -I "http://yourhost/gitea//avatars/a" ``` Fixes #27409 --- Note: the diff looks big but it's actually a small change - all I did was to remove the outer closure (and one level of indentation) ~and removed the HTTP method and pattern checks as they seem redundant because go-chi already does those checks~. You might want to check "Hide whitespace" when reviewing it. Alternative solution (a bit simpler): append `, misc.DummyOK` to the route declarations that utilize `storageHandler()` - this makes it return an empty response when the URL is invalid. I've tested this one and it works too. Or maybe it would be better to return a 400 error in that case (?) Co-authored-by: Sergey Zolotarev <[email protected]>
I was unable to create a backport for 1.20. @sryze, please send one manually. 🍵
|
I was unable to create a backport for 1.21. @sryze, please send one manually. 🍵
|
I think the bot is trying to backport the same commit twice as it appears to be already in those release branches. |
* giteaoffical/main: (79 commits) Pre-register OAuth application for tea (go-gitea#27509) Fix mermaid flowchart margin issue (go-gitea#27503) add a shortcut to user's profile page to admin user details (go-gitea#27299) Fix actionlint (go-gitea#27513) [skip ci] Updated translations via Crowdin Update JS and PY dependencies (go-gitea#27501) Improve feed icons and feed merge text color (go-gitea#27498) Downgrade `go-co-op/gocron` to v1.31.1 (go-gitea#27511) Enable markdownlint `no-duplicate-header` (go-gitea#27500) bump go-deps (go-gitea#27489) Apply to became a maintainer (go-gitea#27491) change runner for binary [skip ci] Updated translations via Crowdin Remove .exe suffix when cross-compiling on Windows (go-gitea#27448) move re-useable workflow add checkout to disk-clean use hosted runners for nightly actions (go-gitea#27485) Avoid run change title process when the title is same (go-gitea#27467) Fix panic in storageHandler (go-gitea#27446) Rename the default themes to gitea-light, gitea-dark, gitea-auto (go-gitea#27419) ...
storageHandler() is written as a middleware but is used as an endpoint handler, and thus
next
is actuallynil
, which causes a null pointer dereference when a request URL does not match the pattern (where it callsnext.ServerHTTP()
).Example CURL command to trigger the panic:
Fixes #27409
Note: the diff looks big but it's actually a small change - all I did was to remove the outer closure (and one level of indentation)
and removed the HTTP method and pattern checks as they seem redundant because go-chi already does those checks. You might want to check "Hide whitespace" when reviewing it.Alternative solution (a bit simpler): append
, misc.DummyOK
to the route declarations that utilizestorageHandler()
- this makes it return an empty response when the URL is invalid. I've tested this one and it works too. Or maybe it would be better to return a 400 error in that case (?)