Browse Source

make sure a short packet doesn't cause an assert failure...

irr_shared
John-Mark Gurney 2 years ago
parent
commit
5642c46c66
2 changed files with 10 additions and 0 deletions
  1. +4
    -0
      comms.c
  2. +6
    -0
      lora.py

+ 4
- 0
comms.c View File

@@ -98,6 +98,10 @@ _comms_process_session(struct comms_state *cs, struct comms_session *sess, struc

strobe_attach_buffer(&sess->cs_crypto, pbin.pkt, pbin.pktlen);

/* if the packet is too short, ignore */
if (pbin.pktlen < MAC_LEN)
goto badmsg;

cnt = strobe_get(&sess->cs_crypto, APP_CIPHERTEXT, buf, pbin.pktlen -
MAC_LEN);
msglen = cnt;


+ 6
- 0
lora.py View File

@@ -762,6 +762,12 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):

self.assertFalse(out)

# that varous short messages don't cause problems
for i in range(10):
out = lora_comms.comms_process_wrap(commstate, b'0' * i)

self.assertFalse(out)

# copy the crypto state
cstate = l.st.copy()



Loading…
Cancel
Save