From a1a783892f34383c3583fa47a0124edbd7329a2e Mon Sep 17 00:00:00 2001 From: "Dolf Schimmel (Freeaqingme)" Date: Sun, 3 Apr 2016 18:58:25 +0200 Subject: [PATCH] Improve error handling on parse error --- conn.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/conn.go b/conn.go index 6e9f9aa..5c9f7f9 100644 --- a/conn.go +++ b/conn.go @@ -118,6 +118,7 @@ func parseResult(line string) *ScanResult { matches := resultRegex.FindStringSubmatch(line) if len(matches) == 0 { + res.Description = "Regex had no matches" res.Status = RES_PARSE_ERROR return res } @@ -136,6 +137,16 @@ func parseResult(line string) *ScanResult { res.Size = i } case "status": + switch matches[i] { + case RES_OK: + case RES_FOUND: + case RES_ERROR: + break + default: + res.Description = "Invalid status field: " + matches[i] + res.Status = RES_PARSE_ERROR + return res + } res.Status = matches[i] } }