From 0ea3e338ab66b93938e62f9d3a76609a7dcc2619 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Thu, 29 Jun 2023 16:27:17 +0200 Subject: [PATCH] Codechange: replace buffer+strecpy with std::string --- src/network/network_content.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index c79bb1c012..e30bbbff98 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -699,19 +699,19 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l check_not_null(p); p++; // Start after the '/' - char tmp[MAX_PATH]; - if (strecpy(tmp, p, lastof(tmp)) == lastof(tmp)) { - this->OnFailure(); - return; - } + std::string filename = p; /* Remove the extension from the string. */ for (uint i = 0; i < 2; i++) { - p = strrchr(tmp, '.'); - check_and_terminate(p); + auto pos = filename.find_last_of('.'); + if (pos == std::string::npos) { + this->OnFailure(); + return; + } + filename.erase(pos); } /* Copy the string, without extension, to the filename. */ - this->curInfo->filename = tmp; + this->curInfo->filename = std::move(filename); /* Request the next file. */ if (!this->BeforeDownload()) {