Possible fix to #167

master
Ismael Gomez 7 years ago
parent 622b3221d7
commit 682ed433b2

@ -134,10 +134,15 @@ public:
void parse_packet(uint8_t *ptr) {
uint8_t *init_ptr = ptr;
nof_subheaders = 0;
while(subheaders[nof_subheaders].read_subheader(&ptr)) {
nof_subheaders++;
bool ret = false;
do {
if (nof_subheaders < (int) max_subheaders) {
ret = subheaders[nof_subheaders].read_subheader(&ptr);
}
} while (ret && nof_subheaders < (int) max_subheaders);
if (nof_subheaders + 1 < (int) max_subheaders) {
nof_subheaders++;
}
for (int i=0;i<nof_subheaders;i++) {
subheaders[i].read_payload(&ptr);
}

@ -122,7 +122,7 @@ uint8_t* sch_pdu::write_packet(srslte::log *log_h)
sch_subh padding;
padding.set_padding();
if (nof_subheaders <= 0) {
if (nof_subheaders <= 0 && nof_subheaders < max_subheaders) {
log_h->error("Trying to write packet with invalid number of subheaders (nof_subheaders=%d).\n", nof_subheaders);
log_h->console("Trying to write packet with invalid number of subheaders (nof_subheaders=%d).\n", nof_subheaders);
return NULL;

Loading…
Cancel
Save