summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHåkon Nessjøen <haakon.nessjoen@gmail.com>2011-11-02 20:42:17 +0100
committerHåkon Nessjøen <haakon.nessjoen@gmail.com>2011-11-02 20:42:17 +0100
commit75ff364cd556c1ad8cfe742f0d58d5751807c111 (patch)
tree977b4374202896e505952fa849ca3a48d07437eb
parent2df57f592c0760b15707e87537e29aebaa83ee87 (diff)
downloadMAC-Telnet-75ff364cd556c1ad8cfe742f0d58d5751807c111.tar.gz
MAC-Telnet-75ff364cd556c1ad8cfe742f0d58d5751807c111.zip
Buffer overflow prevention.
-rw-r--r--protocol.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/protocol.c b/protocol.c
index 5800a7e..d9ba0a1 100644
--- a/protocol.c
+++ b/protocol.c
@@ -221,6 +221,11 @@ int parse_control_packet(unsigned char *packetdata, int data_len, struct mt_mact
/* Control packet data length */
memcpy(&(cpkthdr->length), data + 5, sizeof(cpkthdr->length));
cpkthdr->length = ntohl(cpkthdr->length);
+
+ /* We want no buffer overflows */
+ if (cpkthdr->length >= MT_PACKET_LEN - 22 - int_pos) {
+ cpkthdr->length = MT_PACKET_LEN - 1 - 22 - int_pos;
+ }
/* Set pointer to actual data */
cpkthdr->data = data + 9;