1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-11-22 04:50:06 +00:00

laikaS_endInPacket() bug fix

- sock->inCount was not properly set
This commit is contained in:
CPunch 2022-02-03 16:46:12 -06:00
parent dd173ee422
commit 5fe72e9eb0
2 changed files with 4 additions and 1 deletions

View File

@ -12,7 +12,7 @@ void handleHandshakeResponse(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
uint8_t endianness = laikaS_readByte(&peer->sock); uint8_t endianness = laikaS_readByte(&peer->sock);
peer->sock.flipEndian = endianness != laikaS_isBigEndian(); 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] = { PeerPktHandler laikaB_handlerTbl[LAIKAPKT_MAXNONE] = {

View File

@ -234,6 +234,9 @@ int laikaS_endInPacket(struct sLaika_socket *sock) {
LAIKA_ERROR("Failed to decrypt packet!\n") LAIKA_ERROR("Failed to decrypt packet!\n")
} }
/* decrypted message is smaller now */
sock->inCount -= crypto_secretbox_MACBYTES;
/* remove nonce */ /* remove nonce */
laikaM_rmvarray(sock->inBuf, sock->inCount, sock->inStart, crypto_secretbox_NONCEBYTES); laikaM_rmvarray(sock->inBuf, sock->inCount, sock->inStart, crypto_secretbox_NONCEBYTES);