mirror of
https://github.com/slackhq/nebula.git
synced 2026-08-16 18:37:04 +02:00
outside: drop oversized test requests regardless of log level
The return lived inside a log-level-gated else-if, so with debug logging off, control fell out of both switches. Nothing follows the switch today, making it a silent drop by luck; any future code added after the switch would have run for oversized Test requests only when debug logging was disabled. Make the drop a guard clause. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ugV2edVqoz3tBvq9J6yWp
This commit is contained in:
+5
-4
@@ -161,13 +161,14 @@ func (f *Interface) readOutsidePackets(via ViaSender, scratch []byte, packet []b
|
|||||||
case header.TestRequest:
|
case header.TestRequest:
|
||||||
const maxCipherOverhead = 16 //todo we use this too often, needs a real importable const
|
const maxCipherOverhead = 16 //todo we use this too often, needs a real importable const
|
||||||
const maxOverhead = header.Len + header.Len + maxCipherOverhead + maxCipherOverhead
|
const maxOverhead = header.Len + header.Len + maxCipherOverhead + maxCipherOverhead
|
||||||
if maxOverhead+len(out) <= len(scratch) {
|
if maxOverhead+len(out) > len(scratch) {
|
||||||
f.send(header.Test, header.TestReply, hostinfo.ConnectionState, hostinfo, out, nb, scratch[:0])
|
// A reply that cannot fit in scratch is dropped no matter the log level.
|
||||||
return
|
if f.l.Enabled(context.Background(), slog.LevelDebug) {
|
||||||
} else if f.l.Enabled(context.Background(), slog.LevelDebug) {
|
|
||||||
hostinfo.logger(f.l).Debug("dropping oversized test request", "payloadLen", len(out), "from", via)
|
hostinfo.logger(f.l).Debug("dropping oversized test request", "payloadLen", len(out), "from", via)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
f.send(header.Test, header.TestReply, hostinfo.ConnectionState, hostinfo, out, nb, scratch[:0])
|
||||||
default:
|
default:
|
||||||
hostinfo.logger(f.l).Error("IsValidSubType was true, but unexpected test subtype seen", "from", via, "header", h)
|
hostinfo.logger(f.l).Error("IsValidSubType was true, but unexpected test subtype seen", "from", via, "header", h)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user