From 63f6a416780d3f8f8c698862449b23c3168c9873 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Thu, 26 Nov 2020 14:42:21 +0100 Subject: [PATCH] fix udppunch whisper parsing --- src/network/online_service.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/online_service.cpp b/src/network/online_service.cpp index 0fbbb47c0..8a59a5215 100644 --- a/src/network/online_service.cpp +++ b/src/network/online_service.cpp @@ -1443,9 +1443,9 @@ private: if (!text.empty()) { std::string prefix = "/udppunch "; unsigned int a, b, c, d, ip, port; - if (text.size() > prefix.size() && text.rfind(prefix, 0)) { - int res = sscanf(text.substr(prefix.size()).c_str(), "%uhh.%uhh.%uhh.%uhh:%d", &d, &c, &b, &a, &port); - if (res == 5) { + if (text.size() > prefix.size() && text.rfind(prefix, 0) != std::string::npos) { + int res = sscanf(text.substr(prefix.size()).c_str(), "%d.%d.%d.%d:%d", &a, &b, &c, &d, &port); + if (res == 5 && a < 255 && b < 255 && c < 255 && d < 255 && port > 1024) { ip = a | b << 8 | c << 16 | d << 24; if (NetConnectType == 1 && !GameRunning) { // the server, waiting for clients const CInitMessage_Header message(MessageInit_FromServer, ICMAYT);