Fix MSG_Read*String*() functions not being able to read last byte from message

This is exact root of q3msgboom bug http://aluigi.altervista.org/adv/q3msgboom-adv.txt
Unfortunately, server still need this ugly '1022 char limit' hack to support unfixed clients in some degree.
And as it affects MSG_ReadBigString() - unfixed clients can still be crashed by 8191-chars long configstrings that comes with gamestate
This commit is contained in:
Eugene C 2018-04-04 06:36:24 +03:00 committed by Zack Middleton
parent 3bf48877f3
commit 9f294ce520

View file

@ -462,12 +462,14 @@ char *MSG_ReadString( msg_t *msg ) {
if ( c > 127 ) {
c = '.';
}
string[l] = c;
l++;
} while (l < sizeof(string)-1);
// break only after reading all expected data from bitstream
if ( l >= sizeof(string)-1 ) {
break;
}
string[l++] = c;
} while (1);
string[l] = 0;
string[l] = '\0';
return string;
}
@ -490,12 +492,14 @@ char *MSG_ReadBigString( msg_t *msg ) {
if ( c > 127 ) {
c = '.';
}
string[l] = c;
l++;
} while (l < sizeof(string)-1);
// break only after reading all expected data from bitstream
if ( l >= sizeof(string)-1 ) {
break;
}
string[l++] = c;
} while (1);
string[l] = 0;
string[l] = '\0';
return string;
}
@ -518,12 +522,14 @@ char *MSG_ReadStringLine( msg_t *msg ) {
if ( c > 127 ) {
c = '.';
}
string[l] = c;
l++;
} while (l < sizeof(string)-1);
// break only after reading all expected data from bitstream
if ( l >= sizeof(string)-1 ) {
break;
}
string[l++] = c;
} while (1);
string[l] = 0;
string[l] = '\0';
return string;
}