From e278afa57d950dcbd6c91c72733cd552a01ef20a Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 9 Sep 2020 17:16:13 +0000 Subject: [PATCH] Handle too-short response in s7-info. See #2117 --- scripts/s7-info.nse | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/s7-info.nse b/scripts/s7-info.nse index c9280b7d4..db58c7cf7 100644 --- a/scripts/s7-info.nse +++ b/scripts/s7-info.nse @@ -128,6 +128,10 @@ local function second_parse_response(response, output) -- change offset to 4, this is where most of valid PLCs will fall offset = 4 end + if #response < 142 + offset then + stdnse.debug1("Short response cannot be parsed.") + return nil + end -- parse system name output["System Name"] = string.unpack("z", response, 40 + offset) -- parse module type