From 1a45c11dfb7a07764ed8a7745b93cbbdc263a8c4 Mon Sep 17 00:00:00 2001 From: Simon Maddocks Date: Wed, 2 Feb 2022 23:12:08 +0000 Subject: [PATCH] Add check for packets missing a nonce --- Romulus-M/encrypt_wrapper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Romulus-M/encrypt_wrapper.c b/Romulus-M/encrypt_wrapper.c index 0737e4a..ffff5f3 100644 --- a/Romulus-M/encrypt_wrapper.c +++ b/Romulus-M/encrypt_wrapper.c @@ -125,6 +125,11 @@ int decrypt(packetEx *packet, unsigned char *inBuf, UINT16 len, unsigned char *k // n = nonce, CRYPTO_NPUBBYTES size 16 unsigned char *npub = &inBuf[loc]; loc += CRYPTO_NPUBBYTES; + + if ((len - loc) < 0 ) + { + return 1; + } // ciphertext - in, MAX 16 bytes larger than plaintext - defined as CRYPTO_ABYTES int clen = len - loc;