diff options
| author | Xe Iaso <me@xeiaso.net> | 2025-03-17 01:16:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-17 01:16:27 -0400 |
| commit | 8a74242450af43ced1b810c2da1eba8319285fbc (patch) | |
| tree | 7031b50ed6509b9ce22ff8de7628d2771da33237 | |
| parent | 879a03518fe3ab113195a34015457d203058b4d8 (diff) | |
| download | x-anubis/admin-configured-deny-rule-hashes.tar.xz x-anubis/admin-configured-deny-rule-hashes.zip | |
cmd/anubis: remove theoretical nil pointer deference panic
anubis/admin-configured-deny-rule-hashes
This won't actually happen in real life, but the code paths might change so we should be somewhat defensive.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| -rw-r--r-- | cmd/anubis/main.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index 683fd7a..de0a592 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -287,6 +287,11 @@ func (s *Server) maybeReverseProxy(w http.ResponseWriter, r *http.Request) { case config.RuleDeny: clearCookie(w) lg.Info("explicit deny") + if rule == nil { + lg.Error("rule is nil, cannot calculate checksum") + templ.Handler(base("Oh noes!", errorPage("Other internal server error (contact the admin)")), templ.WithStatus(http.StatusInternalServerError)).ServeHTTP(w, r) + return + } hash, err := rule.Hash() if err != nil { lg.Error("can't calculate checksum of rule", "err", err) |
