From 4c0daa191c7e11d140e1b423365f4d3099cab8c8 Mon Sep 17 00:00:00 2001 From: Yashwini Krishna Murthy Date: Thu, 15 Oct 2026 02:15:37 -0400 Subject: [PATCH] Handle duplicate SSDP discovery responses --- nselib/upnp.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/nselib/upnp.lua b/nselib/upnp.lua index f24bcb1f1..fac5c7e2b 100644 --- a/nselib/upnp.lua +++ b/nselib/upnp.lua @@ -200,8 +200,28 @@ Comm = { output.location = location end + -- Ignore repeated SSDP responses without aborting discovery. + -- Preserve distinct USNs reported by the same host. if key and results[key] then - return false, "Already recorded a response for this host" + local existing = results[key] + + if usn and usn ~= existing.usn then + local devices = existing.ssdp_devices or {} + + for _, device in ipairs(devices) do + if device.usn == usn then + return true + end + end + + devices[#devices + 1] = { + usn = usn, + location = location + } + existing.ssdp_devices = devices + end + + return true end local server = string.match(response, "\n[Ss][Ee][Rr][Vv][Ee][Rr]:%s*(.-)\r?\n")