Merge pull request #177 from junliangtan/master

fixed the crash issue when len is minus caused by invalid data.
This commit is contained in:
Linwei 2018-11-02 04:29:15 +08:00 committed by GitHub
commit 2df2110e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
ikcp.c
View File

@ -772,7 +772,7 @@ int ikcp_input(ikcpcb *kcp, const char *data, long size)
size -= IKCP_OVERHEAD;
if ((long)size < (long)len) return -2;
if ((long)size < (long)len || (int)len < 0) return -2;
if (cmd != IKCP_CMD_PUSH && cmd != IKCP_CMD_ACK &&
cmd != IKCP_CMD_WASK && cmd != IKCP_CMD_WINS)