Skip to content

Commit c4c9f1e

Browse files
committed
Validate Arg Buff
1 parent 31282aa commit c4c9f1e

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

Svc/FpySequencer/FpySequencer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ class FpySequencer : public FpySequencerComponentBase {
634634
// live running computation of CRC (updated as we read)
635635
U32 m_computedCRC;
636636

637+
// Size of arguments read in current sequence. Used for validation between
638+
// User provided arguments and what is requested of the sequence.
639+
Fpy::StackSizeType m_totalReadArgumentSize{0};
640+
637641
// whether or not the sequence we're about to run should return immediately or
638642
// block on completion
639643
FpySequencer_BlockState m_sequenceBlockState;

Svc/FpySequencer/FpySequencerValidationState.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Fw::Success FpySequencer::validate() {
7373
if (readStatus != Fw::Success::SUCCESS) {
7474
return Fw::Success::FAILURE;
7575
}
76-
76+
7777
// read footer bytes but don't include in CRC
7878
readStatus = this->readBytes(sequenceFile, Fpy::Footer::SERIALIZED_SIZE, FpySequencer_FileReadStage::FOOTER, false);
7979

@@ -147,7 +147,7 @@ Fw::Success FpySequencer::readBody() {
147147
Fw::SerializeStatus deserStatus;
148148

149149
const U8 argumentCount = this->m_sequenceObj.get_header().get_argumentCount();
150-
Fpy::StackSizeType totalExpectedSize = 0;
150+
this->m_totalReadArgumentSize = 0;
151151

152152
// deser arguments
153153
// Read and deserialize each arg_spec incrementally since they're variable-length
@@ -201,13 +201,21 @@ Fw::Success FpySequencer::readBody() {
201201
}
202202

203203
// Check for overflow before accumulation
204-
if (totalExpectedSize > Fpy::MAX_STACK_SIZE - argSize) {
204+
if (m_totalReadArgumentSize > Fpy::MAX_STACK_SIZE - argSize) {
205205
this->log_WARNING_HI_ArgTotalSizeExceedsStackLimit(argSize, Fpy::MAX_STACK_SIZE,
206206
this->m_sequenceFilePath);
207207
return Fw::Success::FAILURE;
208208
}
209209
argSpec.set_argSize(argSize);
210-
totalExpectedSize += argSize;
210+
m_totalReadArgumentSize += argSize;
211+
}
212+
213+
// Validate total argument size
214+
if (this->m_totalReadArgumentSize != this->m_sequenceArgs.get_size()){
215+
this->log_WARNING_HI_ArgSizeMismatch(this->m_sequenceObj.get_header().get_argumentCount(),
216+
this->m_sequenceArgs.get_size(),
217+
this->m_sequenceFilePath);
218+
return Fw::Success::FAILURE;
211219
}
212220

213221
// deser statements

0 commit comments

Comments
 (0)