From 473ca6dcf4789259ec4543d7d648bd1bd19986fc Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 14 Mar 2023 12:17:05 +0100 Subject: [PATCH] detect: bytemath do not left shift more than 64 As it is undefined behavior by C standard. In this case, zeroes the value. Ticket: #5900 --- src/detect-bytemath.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/detect-bytemath.c b/src/detect-bytemath.c index 1aa55b5e63..a93144e265 100644 --- a/src/detect-bytemath.c +++ b/src/detect-bytemath.c @@ -168,7 +168,11 @@ int DetectByteMathDoMatch(DetectEngineThreadCtx *det_ctx, const SigMatchData *sm val *= rvalue; break; case LeftShift: - val <<= rvalue; + if (rvalue < 64) { + val <<= rvalue; + } else { + val = 0; + } break; case RightShift: val >>= rvalue; -- 2.47.2