From 1f6427bf9af81bd280ced75fa18ba9f17ff1c1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Cebri=C3=A1n=20Juan?= Date: Tue, 7 May 2019 18:24:38 +0200 Subject: [PATCH] Fix argument parsing for warmstart and hotstart commands --- src/core/receiver/tcp_cmd_interface.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/receiver/tcp_cmd_interface.cc b/src/core/receiver/tcp_cmd_interface.cc index f6f549735..29e62d6e0 100644 --- a/src/core/receiver/tcp_cmd_interface.cc +++ b/src/core/receiver/tcp_cmd_interface.cc @@ -175,9 +175,11 @@ std::string TcpCmdInterface::hotstart(const std::vector &commandLin std::string response; if (commandLine.size() > 5) { + std::string tmp_str; // Read commandline time parameter struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; - if (strptime(commandLine.at(1).c_str(), "%d/%m/%Y %H:%M:%S", &tm) == nullptr) + tmp_str = commandLine.at(1) + commandLine.at(2); + if (strptime(tmp_str.c_str(), "%d/%m/%Y %H:%M:%S", &tm) == nullptr) { response = "ERROR: time parameter malformed\n"; return response; @@ -224,7 +226,7 @@ std::string TcpCmdInterface::warmstart(const std::vector &commandLi // Read commandline time parameter struct tm tm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; tmp_str = commandLine.at(1) + commandLine.at(2); - if (strptime(commandLine.at(1).c_str(), "%d/%m/%Y %H:%M:%S", &tm) == nullptr) + if (strptime(tmp_str.c_str(), "%d/%m/%Y %H:%M:%S", &tm) == nullptr) { response = "ERROR: time parameter malformed\n"; return response; @@ -235,6 +237,7 @@ std::string TcpCmdInterface::warmstart(const std::vector &commandLi rx_latitude_ = std::stod(commandLine.at(3).c_str()); rx_longitude_ = std::stod(commandLine.at(4).c_str()); rx_altitude_ = std::stod(commandLine.at(5).c_str()); + if (std::isnan(rx_latitude_) || std::isnan(rx_longitude_) || std::isnan(rx_altitude_)) { response = "ERROR: position malformed\n";