Skip to content

Commit

Permalink
receive length check bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
gioblu committed Sep 13, 2017
1 parent c38a4a0 commit e1b97e2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions PJON.h
Expand Up @@ -427,12 +427,18 @@ class PJON {

if((i == (2 + extended_header)) && !extended_length) {
length = data[i];
if(length < 5 || length > PJON_PACKET_MAX_LENGTH) return PJON_FAIL;
if(
length < (overhead + !async_ack) ||
length >= PJON_PACKET_MAX_LENGTH
) return PJON_FAIL;
}

if((i == (3 + extended_header)) && extended_length) {
length = (data[i - 1] << 8) | (data[i] & 0xFF);
if(length < 5 || length > PJON_PACKET_MAX_LENGTH) return PJON_FAIL;
if(
length < (overhead + !async_ack) ||
length >= PJON_PACKET_MAX_LENGTH
) return PJON_FAIL;
}

if((config & PJON_MODE_BIT) && (data[1] & PJON_MODE_BIT) && !_router)
Expand Down

0 comments on commit e1b97e2

Please sign in to comment.