From 5fe72e9eb09e1a8ce08f21394fcc666e5f60df15 Mon Sep 17 00:00:00 2001 From: CPunch Date: Thu, 3 Feb 2022 16:46:12 -0600 Subject: [PATCH] laikaS_endInPacket() bug fix - sock->inCount was not properly set --- bot/src/bot.c | 2 +- lib/src/lsocket.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/src/bot.c b/bot/src/bot.c index 905b069..2ebdeab 100644 --- a/bot/src/bot.c +++ b/bot/src/bot.c @@ -12,7 +12,7 @@ void handleHandshakeResponse(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u uint8_t endianness = laikaS_readByte(&peer->sock); peer->sock.flipEndian = endianness != laikaS_isBigEndian(); - LAIKA_DEBUG("handshake accepted by cnc! got endian flag : %s\n", (endianness ? "TRUE" : "FALSE")) + LAIKA_DEBUG("handshake accepted by cnc! got endian flag : %s\n", (endianness ? "TRUE" : "FALSE")); } PeerPktHandler laikaB_handlerTbl[LAIKAPKT_MAXNONE] = { diff --git a/lib/src/lsocket.c b/lib/src/lsocket.c index e709653..abb51ee 100644 --- a/lib/src/lsocket.c +++ b/lib/src/lsocket.c @@ -234,6 +234,9 @@ int laikaS_endInPacket(struct sLaika_socket *sock) { LAIKA_ERROR("Failed to decrypt packet!\n") } + /* decrypted message is smaller now */ + sock->inCount -= crypto_secretbox_MACBYTES; + /* remove nonce */ laikaM_rmvarray(sock->inBuf, sock->inCount, sock->inStart, crypto_secretbox_NONCEBYTES);