From bf12f284faa2938254794f00d18883be38d3645b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 10:53:04 +0100 Subject: [PATCH 1/4] add size and crc check for contained TC --- src/fsfw/pus/Service11TelecommandScheduling.h | 2 ++ src/fsfw/pus/Service11TelecommandScheduling.tpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index aa958193..83b2b4c0 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -41,6 +41,8 @@ class Service11TelecommandScheduling final : public PusServiceBase { static constexpr ReturnValue_t INVALID_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 2); static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 3); static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t CONTAINED_TC_TOO_SMALL = returnvalue::makeCode(CLASS_ID, 5); + static constexpr ReturnValue_t CONTAINED_TC_CRC_MISSMATCH = returnvalue::makeCode(CLASS_ID, 6); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 9016af80..8bf92460 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -6,6 +6,8 @@ #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" +#include "fsfw/globalfunctions/CRC.h": static constexpr auto DEF_END = SerializeIF::Endianness::BIG; @@ -171,6 +173,14 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi return returnvalue::FAILED; } + if (size < PusTcIF::MIN_SIZE) { + return CONTAINED_TC_TOO_SMALL; + } + + if (CRC::crc16ccitt(data, size) != 0) { + return CONTAINED_TC_CRC_MISSMATCH; + } + // store currentPacket and receive the store address store_address_t addr{}; if (tcStore->addData(&addr, data, size) != returnvalue::OK || From 97c629ad8446ff9525dd29f3211e0041cb469532 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 10:53:36 +0100 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80338446..f738032f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- TC Scheduler Service 11: Add size and CRC check for contained TC. - Only delete health table entry in `HealthHelper` destructor if health table was set. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/710/files From a4531e4ced145832e271f846da533d75fc4ae5c2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 10:59:39 +0100 Subject: [PATCH 3/4] typo --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 8bf92460..cbfa3103 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -7,7 +7,7 @@ #include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" -#include "fsfw/globalfunctions/CRC.h": +#include "fsfw/globalfunctions/CRC.h" static constexpr auto DEF_END = SerializeIF::Endianness::BIG; From d16c5024dc7ece711afe88b156fe16aae6f4bd80 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 11:15:36 +0100 Subject: [PATCH 4/4] small include improvement --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index cbfa3103..540f6c68 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -6,7 +6,7 @@ #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" #include "fsfw/globalfunctions/CRC.h" static constexpr auto DEF_END = SerializeIF::Endianness::BIG;