From 06bd8baef635939ed4df8ca5e5d2b9a7ca58b355 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Mon, 10 Jan 2011 12:19:13 -0800 Subject: [PATCH] Fix for portmapper analyzer segfaulting when parsing portmap dump replies. (Gregor Maier) Closes #332. --- src/portmap-analyzer.pac | 4 ++++ src/portmap-protocol.pac | 1 + 2 files changed, 5 insertions(+) diff --git a/src/portmap-analyzer.pac b/src/portmap-analyzer.pac index 546be2e9cc..1e7921a9ff 100644 --- a/src/portmap-analyzer.pac +++ b/src/portmap-analyzer.pac @@ -79,6 +79,10 @@ function PortmapBuildDumpVal(params: PortmapDumpResults): BroVal for ( int i = 0; i < params->size(); ++i ) { + // The last element has cont()!=1 and this element doesn't contain a + // mapping. + if ((*params)[i]->cont() != 1) + continue; Val* m = PortmapBuildMappingVal((*params)[i]->mapping()); Val* index = new Val(i + 1, TYPE_COUNT); mappings->Assign(index, m); diff --git a/src/portmap-protocol.pac b/src/portmap-protocol.pac index d9f3e5be97..65a478fb2d 100644 --- a/src/portmap-protocol.pac +++ b/src/portmap-protocol.pac @@ -68,6 +68,7 @@ type PortmapDumpEntry = record { }; }; +# The final element that has cont!=1 will be included in the array. type PortmapDumpResults = PortmapDumpEntry[] &until($element.cont != 1); type PortmapCallItResults = record {