make all the multi-byte MSG_Read* functions update msg->readcount when the

end of the buffer is hit so subsequent MSG_Read* calls for smaller values
error as well. Also add a check for badread in MSG_ReadFloat
This commit is contained in:
Bill Currie 2001-10-18 04:14:18 +00:00
parent ece4e5c6ef
commit 1b1955551a

View file

@ -201,6 +201,7 @@ MSG_ReadShort (msg_t *msg)
int c;
if (msg->readcount + 2 > msg->message->cursize) {
msg->readcount = msg->message->cursize;
msg->badread = true;
return -1;
}
@ -219,6 +220,7 @@ MSG_ReadLong (msg_t *msg)
int c;
if (msg->readcount + 4 > msg->message->cursize) {
msg->readcount = msg->message->cursize;
msg->badread = true;
return -1;
}
@ -242,6 +244,12 @@ MSG_ReadFloat (msg_t *msg)
int l;
} dat;
if (msg->readcount + 4 > msg->message->cursize) {
msg->readcount = msg->message->cursize;
msg->badread = true;
return -1;
}
dat.b[0] = msg->message->data[msg->readcount];
dat.b[1] = msg->message->data[msg->readcount + 1];
dat.b[2] = msg->message->data[msg->readcount + 2];