From 691be8cd08adef56e92c92cbbca38782a0ee6305 Mon Sep 17 00:00:00 2001 From: Anonymous-275 Date: Wed, 2 Jun 2021 00:02:50 +0300 Subject: [PATCH] Mod validity check --- src/Network/Resources.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Network/Resources.cpp b/src/Network/Resources.cpp index c3bd526..1a801ef 100755 --- a/src/Network/Resources.cpp +++ b/src/Network/Resources.cpp @@ -211,6 +211,11 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s return Ret; } +void InvalidResource(const std::string& File){ + UUl("Invalid mod \"" + File + "\""); + warn("The server tried to sync \"" + File + "\" that is not a .zip file!"); + Terminate = true; +} void SyncResources(SOCKET Sock){ std::string Ret = Auth(Sock); @@ -237,6 +242,11 @@ void SyncResources(SOCKET Sock){ t.clear(); for(auto FN = FNames.begin(),FS = FSizes.begin(); FN != FNames.end() && !Terminate; ++FN,++FS) { auto pos = FN->find_last_of('/'); + auto ZIP = FN->find(".zip"); + if (ZIP == std::string::npos || FN->length() - ZIP != 4) { + InvalidResource(*FN); + return; + } if (pos == std::string::npos)continue; Amount++; }