From b7c76ea08a8f98855fd06fe6d3fe9546d03e31bf Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 16 Sep 2022 01:10:20 +0000 Subject: [PATCH] Don't bother allocating space for 'unknown' string. --- services.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services.cc b/services.cc index 7bb49e496..e2c53b456 100644 --- a/services.cc +++ b/services.cc @@ -231,7 +231,15 @@ static int nmap_services_init() { struct service_node sn; - sn.s_name = cp_strdup(servicename); + if (strcmp(servicename, "unknown") == 0) { + // there are a ton (15K+) of ports in our db with this service name, and + // we already write "unknown" if this is NULL, so don't bother allocating + // space for it. + sn.s_name = NULL; + } + else { + sn.s_name = cp_strdup(servicename); + } sn.s_port = portno; sn.s_proto = npe->p_name; sn.ratio = ratio;