From c13ce4536e09be371977f72d32a565662acad736 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 16 Jun 2023 18:20:16 +0000 Subject: [PATCH] Handle 'unknown' service name in -p. Fixes #2658 --- services.cc | 2 ++ utils.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/services.cc b/services.cc index 6631e2d70..493a8475b 100644 --- a/services.cc +++ b/services.cc @@ -285,6 +285,8 @@ int addportsfromservmask(const char *mask, u8 *porttbl, int range_type) { for (i = service_table.begin(); i != service_table.end(); i++) { const service_node& current = i->second; + if (!current.s_name) + continue; if (wildtest(mask, current.s_name)) { if ((range_type & SCAN_TCP_PORT) && strcmp(current.s_proto, "tcp") == 0) { porttbl[current.s_port] |= SCAN_TCP_PORT; diff --git a/utils.cc b/utils.cc index 8a8ec2e60..ea39c639e 100644 --- a/utils.cc +++ b/utils.cc @@ -81,6 +81,8 @@ extern NmapOps o; int wildtest(const char *wild, const char *test) { int i; + assert(wild); + assert(test); while (*wild != '\0' || *test != '\0') { if (*wild == '*') { /* --- Deal with multiple asterisks. --- */