From 6a9e00f6c7abd74d037fd210b6670d3cdb313049 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Wed, 17 Oct 2018 15:12:06 -0500 Subject: [PATCH] Check that the superframe flag is set properly --- C/src/structures.h | 1 + C/src/unpack.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/C/src/structures.h b/C/src/structures.h index ba705ce..67363cf 100644 --- a/C/src/structures.h +++ b/C/src/structures.h @@ -130,6 +130,7 @@ struct Block { }; struct Frame { + int IndexInSuperframe; ConfigData* Config; Channel* Channels[MAX_CHANNEL_COUNT]; Block Blocks[MAX_BLOCK_COUNT]; diff --git a/C/src/unpack.c b/C/src/unpack.c index e2cbf61..8b66e49 100644 --- a/C/src/unpack.c +++ b/C/src/unpack.c @@ -32,7 +32,20 @@ At9Status UnpackFrame(Frame* frame, BitReaderCxt* br) for (int i = 0; i < blockCount; i++) { ERROR_CHECK(UnpackBlock(&frame->Blocks[i], br)); + + if (frame->Blocks[i].FirstInSuperframe && frame->IndexInSuperframe) + { + return ERR_UNPACK_SUPERFRAME_FLAG_INVALID; + } + } + + frame->IndexInSuperframe++; + + if (frame->IndexInSuperframe == frame->Config->FramesPerSuperframe) + { + frame->IndexInSuperframe = 0; } + return ERR_SUCCESS; }