From 332983c97b7a729c4dc5f19aa9ee4a22c420f7d8 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 27 Jun 2023 20:23:44 +1000 Subject: The Formatting String Catastrophe --- source/server/StarServerQueryThread.cpp | 2 +- source/server/StarServerRconClient.cpp | 12 ++++++------ source/server/StarServerRconThread.cpp | 2 +- source/server/main.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source/server') diff --git a/source/server/StarServerQueryThread.cpp b/source/server/StarServerQueryThread.cpp index 446ecbb..2011f42 100644 --- a/source/server/StarServerQueryThread.cpp +++ b/source/server/StarServerQueryThread.cpp @@ -220,7 +220,7 @@ void ServerQueryThread::run() { processPacket(udpAddress, udpData, len); } catch (SocketClosedException const&) { } catch (std::exception const& e) { - Logger::error("ServerQueryThread exception caught: %s", outputException(e, true)); + Logger::error("ServerQueryThread exception caught: {}", outputException(e, true)); } } } diff --git a/source/server/StarServerRconClient.cpp b/source/server/StarServerRconClient.cpp index a42a8ea..91e651b 100644 --- a/source/server/StarServerRconClient.cpp +++ b/source/server/StarServerRconClient.cpp @@ -36,12 +36,12 @@ String ServerRconClient::handleCommand(String commandLine) { return commandLine; } else if (command == "broadcast" || command == "say") { m_universe->adminBroadcast(commandLine); - return strf("OK: said %s", commandLine); + return strf("OK: said {}", commandLine); } else if (command == "stop") { m_universe->stop(); return "OK: shutting down"; } else { - return m_universe->adminCommand(strf("%s %s", command, commandLine)); + return m_universe->adminCommand(strf("{} {}", command, commandLine)); } } @@ -118,17 +118,17 @@ void ServerRconClient::processRequest() { String command; m_packetBuffer >> command; try { - Logger::info("RCON %s: %s", m_socket->remoteAddress(), command); + Logger::info("RCON {}: {}", m_socket->remoteAddress(), command); sendCmdResponse(requestId, handleCommand(command)); } catch (std::exception const& e) { - sendCmdResponse(requestId, strf("RCON: Error executing: %s: %s", command, outputException(e, true))); + sendCmdResponse(requestId, strf("RCON: Error executing: {}: {}", command, outputException(e, true))); } } else { sendAuthFailure(); } break; default: - sendCmdResponse(requestId, strf("Unknown request %06x", cmd)); + sendCmdResponse(requestId, strf("Unknown request {:06x}", cmd)); } } @@ -138,7 +138,7 @@ void ServerRconClient::run() { processRequest(); } catch (NoMoreRequests const&) { } catch (std::exception const& e) { - Logger::error("ServerRconClient exception caught: %s", outputException(e, false)); + Logger::error("ServerRconClient exception caught: {}", outputException(e, false)); } } diff --git a/source/server/StarServerRconThread.cpp b/source/server/StarServerRconThread.cpp index 45f94b3..a9842ee 100644 --- a/source/server/StarServerRconThread.cpp +++ b/source/server/StarServerRconThread.cpp @@ -55,7 +55,7 @@ void ServerRconThread::run() { } } } catch (std::exception const& e) { - Logger::error("ServerRconThread exception caught: %s", e.what()); + Logger::error("ServerRconThread exception caught: {}", e.what()); } } diff --git a/source/server/main.cpp b/source/server/main.cpp index 6522acf..8d734e0 100644 --- a/source/server/main.cpp +++ b/source/server/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) { auto configuration = root->configuration(); { - Logger::info("Server Version %s (%s) Source ID: %s Protocol: %s", StarVersionString, StarArchitectureString, StarSourceIdentifierString, StarProtocolVersion); + Logger::info("Server Version {} ({}) Source ID: {} Protocol: {}", StarVersionString, StarArchitectureString, StarSourceIdentifierString, StarProtocolVersion); UniverseServerUPtr server = make_unique(root->toStoragePath("universe")); server->setListeningTcp(true); -- cgit v1.2.3