Skip to content

Commit

Permalink
Terminate wrong connections to map server after two first bytes received
Browse files Browse the repository at this point in the history
  • Loading branch information
4144 committed Nov 4, 2023
1 parent b097666 commit c2ab350
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -26154,8 +26154,17 @@ static int clif_parse(int fd)
}
}

if ((int)RFIFOREST(fd) < packet_len)
if ((int)RFIFOREST(fd) < packet_len) {
if (sd == NULL) {
if (packet_db[cmd].func != clif->pWantToConnection) {
ShowWarning("clif_parse: Received first unsupported packet (packet 0x%04x (0x%04x), %"PRIuS" bytes received), disconnecting session #%d.\n",
(unsigned int)cmd, RFIFOW(fd, 0), RFIFOREST(fd), fd);
sockt->eof(fd);
}
}

return 0; // not enough data received to form the packet
}

if( battle_config.packet_obfuscation == 2 || cmd != RFIFOW(fd, 0) || (sd && sd->parse_cmd_func == clif->parse_cmd_decrypt) ) {
// Note: Overriding const qualifier to re-inject the decoded packet ID.
Expand Down

0 comments on commit c2ab350

Please sign in to comment.