From 2c8c9b615f156a1207667475c14890db3c2f61b7 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Mon, 20 Feb 2023 08:53:25 +0000 Subject: [PATCH] Fix some bugs. --- engine/common/net_ice.c | 4 ++-- engine/qclib/qcc_pr_lex.c | 2 ++ engine/server/net_preparse.c | 2 ++ engine/server/sv_ccmds.c | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/engine/common/net_ice.c b/engine/common/net_ice.c index 750db26dd..50999ac40 100644 --- a/engine/common/net_ice.c +++ b/engine/common/net_ice.c @@ -3534,7 +3534,7 @@ static void SCTP_Decode(sctp_t *sctp, struct icestate_s *peer, ftenet_connection while ((qbyte*)(c+1) <= msgend) { clen = BigShort(c->length); - if ((qbyte*)c + clen > msgend) + if ((qbyte*)c + clen > msgend || clen < sizeof(*c)) break; //corrupt safeswitch(c->type) { @@ -3587,7 +3587,7 @@ static void SCTP_Decode(sctp_t *sctp, struct icestate_s *peer, ftenet_connection if (adv > sctp->i.htsn) //weird maths in case it wraps. sctp->i.htsn = adv; sctp->i.r.tsn++; - if (sctp->i.r.size + clen-sizeof(*dc) > sizeof(sctp->i.r.buf)) + if (sctp->i.r.size + dlen > sizeof(sctp->i.r.buf)) { if (net_ice_debug.ival >= 2) Con_Printf(S_COLOR_GRAY"[%s]: SCTP: Oversized\n", peer->friendlyname); diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index 49359ccee..d6d781624 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -5826,11 +5826,13 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail) //swap the class out for the appropriate function type... newparm = QCC_PR_GenFunctionType(type_void, basetype->params, basetype->num_parms); parmname = classname; + arraysize = 0; } else if (!flag_qcfuncs && basetype == newt && QCC_PR_CheckToken("(")) { newparm = QCC_PR_ParseFunctionType(false, type_void); parmname = classname; + arraysize = 0; } else { diff --git a/engine/server/net_preparse.c b/engine/server/net_preparse.c index 86fb89601..956617c67 100644 --- a/engine/server/net_preparse.c +++ b/engine/server/net_preparse.c @@ -835,6 +835,7 @@ void NPP_NQFlush(void) break; case svcfte_cgamepacket: + requireextension = PEXT_CSQC; if (sv_csqcdebug.ival || writedest != &sv.multicast) { if (writedest != &sv.multicast) @@ -1919,6 +1920,7 @@ void NPP_QWFlush(void) break; case svcfte_cgamepacket: + requireextension = PEXT_CSQC; if (sv_csqcdebug.ival || writedest != &sv.nqmulticast) { if (writedest != &sv.nqmulticast) diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 47f419fe7..a85fc3a4b 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -3268,6 +3268,11 @@ void SV_PrecacheList_f(void) { unsigned int i; char *group = Cmd_Argv(1); + if (sv.state != ss_active) + { + Con_Printf("Server is not active.\n"); + return; + } #ifdef HAVE_LEGACY if (!*group || !strncmp(group, "vwep", 4)) {