Fix SZ_GetSpace overflows when recording mvds.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5466 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2019-06-03 16:18:47 +00:00
parent c4d339c5c0
commit c975aa55cd
3 changed files with 64 additions and 27 deletions

View file

@ -1378,6 +1378,7 @@ void SV_ReplaceEntityFrame(client_t *cl, int framenum);
// //
void ClientReliableCheckBlock(client_t *cl, int maxsize); void ClientReliableCheckBlock(client_t *cl, int maxsize);
sizebuf_t *ClientReliableWrite_StartWrite(client_t *cl, int maxsize); //MUST be followed by a call to ClientReliable_FinishWrite before the next start
void ClientReliable_FinishWrite(client_t *cl); void ClientReliable_FinishWrite(client_t *cl);
void ClientReliableWrite_Begin(client_t *cl, int c, int maxsize); void ClientReliableWrite_Begin(client_t *cl, int c, int maxsize);
client_t *ClientReliableWrite_BeginSplit(client_t *cl, int svc, int svclen); client_t *ClientReliableWrite_BeginSplit(client_t *cl, int svc, int svclen);

View file

@ -980,6 +980,7 @@ void SV_FullClientUpdate (client_t *client, client_t *to)
{ {
int i; int i;
char info[EXTENDED_INFO_STRING]; char info[EXTENDED_INFO_STRING];
sizebuf_t *buf;
if (!to) if (!to)
{ {
@ -1011,40 +1012,55 @@ void SV_FullClientUpdate (client_t *client, client_t *to)
if (ping > 0xffff) if (ping > 0xffff)
ping = 0xffff; ping = 0xffff;
ClientReliableWrite_Begin(to, svc_updatefrags, 4); buf = ClientReliableWrite_StartWrite(to, 4);
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updatefrags);
ClientReliableWrite_Short(to, client->old_frags); MSG_WriteByte(buf, i);
MSG_WriteShort(buf, client->old_frags);
ClientReliable_FinishWrite(to);
ClientReliableWrite_Begin (to, svc_updateping, 4); buf = ClientReliableWrite_StartWrite(to, 4);
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updateping);
ClientReliableWrite_Short (to, ping); MSG_WriteByte(buf, i);
MSG_WriteShort(buf, ping);
ClientReliable_FinishWrite(to);
ClientReliableWrite_Begin (to, svc_updatepl, 3); buf = ClientReliableWrite_StartWrite(to, 3);
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updatepl);
ClientReliableWrite_Byte (to, client->lossage); MSG_WriteByte(buf, i);
MSG_WriteByte(buf, client->lossage);
ClientReliable_FinishWrite(to);
ClientReliableWrite_Begin (to, svc_updateentertime, 6); buf = ClientReliableWrite_StartWrite(to, 6);
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updateentertime);
ClientReliableWrite_Float (to, realtime - client->connection_started); MSG_WriteByte(buf, i);
MSG_WriteFloat(buf, realtime - client->connection_started);
ClientReliable_FinishWrite(to);
InfoBuf_ToString(&client->userinfo, info, (pext&PEXT_BIGUSERINFOS)?BASIC_INFO_STRING:sizeof(info), basicuserinfos, privateuserinfos, (pext&PEXT_BIGUSERINFOS)?NULL:basicuserinfos, NULL, NULL); InfoBuf_ToString(&client->userinfo, info, (pext&PEXT_BIGUSERINFOS)?BASIC_INFO_STRING:sizeof(info), basicuserinfos, privateuserinfos, (pext&PEXT_BIGUSERINFOS)?NULL:basicuserinfos, NULL, NULL);
ClientReliableWrite_Begin(to, svc_updateuserinfo, 7 + strlen(info)); buf = ClientReliableWrite_StartWrite(to, 7 + strlen(info));
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updateuserinfo);
ClientReliableWrite_Long (to, client->userid); MSG_WriteByte(buf, i);
ClientReliableWrite_String(to, info); MSG_WriteLong(buf, client->userid);
MSG_WriteString(buf, info);
ClientReliable_FinishWrite(to);
} }
else if (ISNQCLIENT(to)) else if (ISNQCLIENT(to))
{ {
int top, bottom, playercolor; int top, bottom, playercolor;
char *nam = InfoBuf_ValueForKey(&client->userinfo, "name"); char *nam = InfoBuf_ValueForKey(&client->userinfo, "name");
ClientReliableWrite_Begin(to, svc_updatefrags, 4); buf = ClientReliableWrite_StartWrite(to, 4);
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updatefrags);
ClientReliableWrite_Short(to, client->old_frags); MSG_WriteByte(buf, i);
MSG_WriteShort(buf, client->old_frags);
ClientReliable_FinishWrite(to);
buf = ClientReliableWrite_StartWrite(to, 3 + strlen(nam));
MSG_WriteByte(buf, svc_updatename);
MSG_WriteByte(buf, i);
MSG_WriteString(buf, nam);
ClientReliable_FinishWrite(to);
ClientReliableWrite_Begin(to, svc_updatename, 3 + strlen(nam));
ClientReliableWrite_Byte (to, i);
ClientReliableWrite_String(to, nam);
top = atoi(InfoBuf_ValueForKey(&client->userinfo, "topcolor")); top = atoi(InfoBuf_ValueForKey(&client->userinfo, "topcolor"));
bottom = atoi(InfoBuf_ValueForKey(&client->userinfo, "bottomcolor")); bottom = atoi(InfoBuf_ValueForKey(&client->userinfo, "bottomcolor"));
@ -1056,17 +1072,21 @@ void SV_FullClientUpdate (client_t *client, client_t *to)
bottom = 13; bottom = 13;
playercolor = top*16 + bottom; playercolor = top*16 + bottom;
ClientReliableWrite_Begin (to, svc_updatecolors, 3); buf = ClientReliableWrite_StartWrite(to, 3);
ClientReliableWrite_Byte (to, i); MSG_WriteByte(buf, svc_updatecolors);
ClientReliableWrite_Byte (to, playercolor); MSG_WriteByte(buf, i);
MSG_WriteByte(buf, playercolor);
ClientReliable_FinishWrite(to);
if (to->fteprotocolextensions2 & PEXT2_PREDINFO) if (to->fteprotocolextensions2 & PEXT2_PREDINFO)
{ {
char *s; char *s;
InfoBuf_ToString(&client->userinfo, info, sizeof(info), basicuserinfos, privateuserinfos, NULL, NULL, NULL); InfoBuf_ToString(&client->userinfo, info, sizeof(info), basicuserinfos, privateuserinfos, NULL, NULL, NULL);
s = va("//fui %i \"%s\"\n", i, info); s = va("//fui %i \"%s\"\n", i, info);
ClientReliableWrite_Begin(to, svc_stufftext, 2+strlen(s)); buf = ClientReliableWrite_StartWrite(to, 2 + strlen(s));
ClientReliableWrite_String(to, s); ClientReliableWrite_Begin(to, svc_stufftext, 2+strlen(s));
ClientReliableWrite_String(to, s);
ClientReliable_FinishWrite(to);
} }
} }
} }

View file

@ -97,6 +97,22 @@ client_t *ClientReliableWrite_BeginSplit(client_t *cl, int svc, int svclen)
} }
} }
sizebuf_t *ClientReliableWrite_StartWrite(client_t *cl, int maxsize)
{
#ifdef MVD_RECORDING
if (cl == &demo.recorder)
return MVDWrite_Begin(dem_all, 0, maxsize);
#endif
if (cl->controller)
Con_Printf("Writing to slave client's message buffer\n");
ClientReliableCheckBlock(cl, maxsize);
if (cl->num_backbuf)
return &cl->backbuf;
else
return &cl->netchan.message;
}
void ClientReliable_FinishWrite(client_t *cl) void ClientReliable_FinishWrite(client_t *cl)
{ {
if (cl->num_backbuf) if (cl->num_backbuf)