if (len_in > 8 && !memcmp(string, "connect\\", 8) && d0_rijndael_dll && crypto_aeslevel.integer >= 3)
{
- const char *s;
int i;
// sorry, we have to verify the challenge here to not reflect network spam
- if (!(s = InfoString_GetValue(string + 4, "challenge", infostringvalue, sizeof(infostringvalue))))
+ if (!InfoString_GetValue(string + 4, "challenge", infostringvalue, sizeof(infostringvalue)))
return CRYPTO_NOMATCH; // will be later accepted if encryption was set up
// validate the challenge
for (i = 0;i < MAX_CHALLENGES;i++)
if(challenges[i].time > 0)
- if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, s))
+ if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, infostringvalue))
break;
// if the challenge is not recognized, drop the packet
if (i == MAX_CHALLENGES) // challenge mismatch is silent
}
else if(len_in > 5 && !memcmp(string, "d0pk\\", 5) && ((LHNETADDRESS_GetAddressType(peeraddress) == LHNETADDRESSTYPE_LOOP) || sv_public.integer > -3))
{
- const char *cnt, *s, *p;
+ const char *cnt, *p;
int id;
int clientid = -1, serverid = -1;
- cnt = InfoString_GetValue(string + 4, "id", infostringvalue, sizeof(infostringvalue));
- id = (cnt ? atoi(cnt) : -1);
- cnt = InfoString_GetValue(string + 4, "cnt", infostringvalue, sizeof(infostringvalue));
+ id = (InfoString_GetValue(string + 4, "id", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1);
+ cnt = (InfoString_GetValue(string + 4, "cnt", infostringvalue, sizeof(infostringvalue)) ? infostringvalue : NULL);
if(!cnt)
return Crypto_SoftServerError(data_out, len_out, "missing cnt in d0pk");
GetUntilNul(&data_in, &len_in);
if(!strcmp(cnt, "0"))
{
int i;
- if (!(s = InfoString_GetValue(string + 4, "challenge", infostringvalue, sizeof(infostringvalue))))
+ if (!InfoString_GetValue(string + 4, "challenge", infostringvalue, sizeof(infostringvalue)))
return Crypto_SoftServerError(data_out, len_out, "missing challenge in d0pk\\0");
// validate the challenge
for (i = 0;i < MAX_CHALLENGES;i++)
if(challenges[i].time > 0)
- if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, s))
+ if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, infostringvalue))
break;
// if the challenge is not recognized, drop the packet
if (i == MAX_CHALLENGES)
return Crypto_SoftServerError(data_out, len_out, "invalid challenge in d0pk\\0");
- if (!(s = InfoString_GetValue(string + 4, "aeslevel", infostringvalue, sizeof(infostringvalue))))
+ if (!InfoString_GetValue(string + 4, "aeslevel", infostringvalue, sizeof(infostringvalue)))
aeslevel = 0; // not supported
else
- aeslevel = bound(0, atoi(s), 3);
+ aeslevel = bound(0, atoi(infostringvalue), 3);
switch(bound(0, d0_rijndael_dll ? crypto_aeslevel.integer : 0, 3))
{
default: // dummy, never happens, but to make gcc happy...
if(len_in > 5 && !memcmp(data_in, "d0pk\\", 5))
{
do_time = true;
- cnt = InfoString_GetValue(data_in + 4, "cnt", infostringvalue, sizeof(infostringvalue));
+ cnt = (InfoString_GetValue(data_in + 4, "cnt", infostringvalue, sizeof(infostringvalue)) ? infostringvalue : NULL);
if(cnt)
if(!strcmp(cnt, "0"))
do_reject = true;
{
crypto_t *crypto = &cls.crypto;
const char *string = data_in;
- const char *s;
D0_BOOL aes;
char *data_out_p = data_out;
D0_BOOL status;
}
else if (len_in >= 13 && !memcmp(string, "infoResponse\x0A", 13))
{
- s = InfoString_GetValue(string + 13, "d0_blind_id", infostringvalue, sizeof(infostringvalue));
- if(s)
- Crypto_StoreHostKey(peeraddress, s, true);
+ if(InfoString_GetValue(string + 13, "d0_blind_id", infostringvalue, sizeof(infostringvalue)))
+ Crypto_StoreHostKey(peeraddress, infostringvalue, true);
return CRYPTO_NOMATCH;
}
else if (len_in >= 15 && !memcmp(string, "statusResponse\x0A", 15))
save = *p;
* (char *) p = 0; // cut off the string there
}
- s = InfoString_GetValue(string + 15, "d0_blind_id", infostringvalue, sizeof(infostringvalue));
- if(s)
- Crypto_StoreHostKey(peeraddress, s, true);
+ if(InfoString_GetValue(string + 15, "d0_blind_id", infostringvalue, sizeof(infostringvalue)))
+ Crypto_StoreHostKey(peeraddress, infostringvalue, true);
if(p)
{
* (char *) p = save;
return Crypto_SoftClientError(data_out, len_out, warn_msg);
}
- cnt = InfoString_GetValue(string + 4, "id", infostringvalue, sizeof(infostringvalue));
- id = (cnt ? atoi(cnt) : -1);
- cnt = InfoString_GetValue(string + 4, "cnt", infostringvalue, sizeof(infostringvalue));
+ id = (InfoString_GetValue(string + 4, "id", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1);
+ cnt = (InfoString_GetValue(string + 4, "cnt", infostringvalue, sizeof(infostringvalue)) ? infostringvalue : NULL);
if(!cnt)
return Crypto_ClientError(data_out, len_out, "d0pk\\ message without cnt");
GetUntilNul(&data_in, &len_in);
cls.connect_nextsendtime = max(cls.connect_nextsendtime, host.realtime + 1); // prevent "hammering"
- if((s = InfoString_GetValue(string + 4, "aes", infostringvalue, sizeof(infostringvalue))))
- aes = atoi(s);
+ if(InfoString_GetValue(string + 4, "aes", infostringvalue, sizeof(infostringvalue)))
+ aes = atoi(infostringvalue);
else
aes = false;
// we CANNOT toggle the AES status any more!
if(CDATA->s < 0) // only if server didn't auth
{
- if((s = InfoString_GetValue(string + 4, "aes", infostringvalue, sizeof(infostringvalue))))
- aes = atoi(s);
+ if(InfoString_GetValue(string + 4, "aes", infostringvalue, sizeof(infostringvalue)))
+ aes = atoi(infostringvalue);
else
aes = false;
if(CDATA->wantserver_idfp[0]) // if we know a host key, honor its encryption setting
size_t sendlength;
#ifdef CONFIG_MENU
char infostringvalue[MAX_INPUTLINE];
- const char *s;
#endif
// quakeworld ingame packet
string += 15;
// search the cache for this server and update it
// the challenge is (ab)used to return the query time
- s = InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
- n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, s);
+ InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
+ n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, infostringvalue);
if (n < 0)
return true;
info = &serverlist_cache[n].info;
- info->game[0] = '\0'; info->game_len = 0;
- info->mod[0] = '\0'; info->mod_len = 0;
- info->map[0] = '\0'; info->map_len = 0;
- info->name[0] = '\0'; info->name_len = 0;
- info->qcstatus[0] = '\0'; info->qcstatus_len = 0;
- info->players[0] = '\0'; info->players_len = 0;
- info->protocol = -1;
- info->numplayers = 0;
- info->numbots = -1;
- info->maxplayers = 0;
- info->gameversion = 0;
-
p = strchr(string, '\n');
if(p)
{
*p = 0; // cut off the string there
++p;
+ info->players_len = dp_strlcpy(info->players, p, sizeof(info->players));
}
else
+ {
Con_Printf("statusResponse without players block?\n");
-
- if ((s = InfoString_GetValue(string, "gamename" , infostringvalue, sizeof(infostringvalue))) != NULL) info->game_len = dp_strlcpy(info->game, s, sizeof(info->game));
- if ((s = InfoString_GetValue(string, "modname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->mod_len = dp_strlcpy(info->mod, s, sizeof(info->mod));
- if ((s = InfoString_GetValue(string, "mapname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->map_len = dp_strlcpy(info->map, s, sizeof(info->map));
- if ((s = InfoString_GetValue(string, "hostname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->name_len = dp_strlcpy(info->name, s, sizeof(info->name));
- if ((s = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue))) != NULL) info->protocol = atoi(s);
- if ((s = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numbots = atoi(s);
- if ((s = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue))) != NULL) info->maxplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue))) != NULL) info->gameversion = atoi(s);
- if ((s = InfoString_GetValue(string, "qcstatus" , infostringvalue, sizeof(infostringvalue))) != NULL) info->qcstatus_len = dp_strlcpy(info->qcstatus, s, sizeof(info->qcstatus));
- if (p != NULL) info->players_len = dp_strlcpy(info->players, p, sizeof(info->players));
+ info->players_len = info->players[0] = 0;
+ }
+ info->game_len = InfoString_GetValue(string, "gamename", info->game, sizeof(info->game));
+ info->mod_len = InfoString_GetValue(string, "modname", info->mod, sizeof(info->mod));
+ info->map_len = InfoString_GetValue(string, "mapname", info->map, sizeof(info->map));
+ info->name_len = InfoString_GetValue(string, "hostname", info->name, sizeof(info->name));
+ info->qcstatus_len = InfoString_GetValue(string, "qcstatus", info->qcstatus, sizeof(info->qcstatus));
+ info->protocol = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->numplayers = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->numbots = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->maxplayers = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->gameversion = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
info->numhumans = info->numplayers - max(0, info->numbots);
info->freeslots = info->maxplayers - info->numplayers;
string += 13;
// search the cache for this server and update it
// the challenge is (ab)used to return the query time
- s = InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
- n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, s);
+ InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue));
+ n = NetConn_ClientParsePacket_ServerList_ProcessReply(addressstring2, infostringvalue);
if (n < 0)
return true;
info = &serverlist_cache[n].info;
- info->game[0] = '\0'; info->game_len = 0;
- info->mod[0] = '\0'; info->mod_len = 0;
- info->map[0] = '\0'; info->map_len = 0;
- info->name[0] = '\0'; info->name_len = 0;
- info->qcstatus[0] = '\0'; info->qcstatus_len = 0;
- info->players[0] = '\0'; info->players_len = 0;
- info->protocol = -1;
- info->numplayers = 0;
- info->numbots = -1;
- info->maxplayers = 0;
- info->gameversion = 0;
-
- if ((s = InfoString_GetValue(string, "gamename" , infostringvalue, sizeof(infostringvalue))) != NULL) info->game_len = dp_strlcpy(info->game, s, sizeof(info->game));
- if ((s = InfoString_GetValue(string, "modname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->mod_len = dp_strlcpy(info->mod, s, sizeof(info->mod));
- if ((s = InfoString_GetValue(string, "mapname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->map_len = dp_strlcpy(info->map, s, sizeof(info->map));
- if ((s = InfoString_GetValue(string, "hostname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->name_len = dp_strlcpy(info->name, s, sizeof(info->name));
- if ((s = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue))) != NULL) info->protocol = atoi(s);
- if ((s = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue))) != NULL) info->numbots = atoi(s);
- if ((s = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue))) != NULL) info->maxplayers = atoi(s);
- if ((s = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue))) != NULL) info->gameversion = atoi(s);
- if ((s = InfoString_GetValue(string, "qcstatus" , infostringvalue, sizeof(infostringvalue))) != NULL) info->qcstatus_len = dp_strlcpy(info->qcstatus, s, sizeof(info->qcstatus));
+ info->players_len = info->players[0] = 0;
+ info->game_len = InfoString_GetValue(string, "gamename", info->game, sizeof(info->game));
+ info->mod_len = InfoString_GetValue(string, "modname", info->mod, sizeof(info->mod));
+ info->map_len = InfoString_GetValue(string, "mapname", info->map, sizeof(info->map));
+ info->name_len = InfoString_GetValue(string, "hostname", info->name, sizeof(info->name));
+ info->qcstatus_len = InfoString_GetValue(string, "qcstatus", info->qcstatus, sizeof(info->qcstatus));
+ info->protocol = InfoString_GetValue(string, "protocol" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->numplayers = InfoString_GetValue(string, "clients" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->numbots = InfoString_GetValue(string, "bots" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : -1;
+ info->maxplayers = InfoString_GetValue(string, "sv_maxclients", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->gameversion = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
info->numhumans = info->numplayers - max(0, info->numbots);
info->freeslots = info->maxplayers - info->numplayers;
#ifdef CONFIG_MENU
serverlist_info_t *info;
int n;
+ const char *s;
// qw server status
if (serverlist_consoleoutput && developer_networking.integer >= 2)
info = &serverlist_cache[n].info;
dp_strlcpy(info->game, "QuakeWorld", sizeof(info->game));
- if ((s = InfoString_GetValue(string, "*gamedir" , infostringvalue, sizeof(infostringvalue))) != NULL) info->mod_len = dp_strlcpy(info->mod, s, sizeof(info->mod));
- else { info->mod[0] = '\0'; info->mod_len = 0; }
- if ((s = InfoString_GetValue(string, "map" , infostringvalue, sizeof(infostringvalue))) != NULL) info->map_len = dp_strlcpy(info->map, s, sizeof(info->map));
- else { info->map[0] = '\0'; info->map_len = 0; }
- if ((s = InfoString_GetValue(string, "hostname" , infostringvalue, sizeof(infostringvalue))) != NULL) info->name_len = dp_strlcpy(info->name, s, sizeof(info->name));
- else { info->name[0] = '\0'; info->name_len = 0; }
+ info->mod_len = InfoString_GetValue(string, "*gamedir", info->mod, sizeof(info->mod));
+ info->map_len = InfoString_GetValue(string, "map" , info->map, sizeof(info->map));
+ info->name_len = InfoString_GetValue(string, "hostname", info->name, sizeof(info->name));
info->protocol = 0;
info->numplayers = 0; // updated below
info->numhumans = 0; // updated below
- if ((s = InfoString_GetValue(string, "maxclients" , infostringvalue, sizeof(infostringvalue))) != NULL) info->maxplayers = atoi(s);else info->maxplayers = 0;
- if ((s = InfoString_GetValue(string, "gameversion" , infostringvalue, sizeof(infostringvalue))) != NULL) info->gameversion = atoi(s);else info->gameversion = 0;
+ info->maxplayers = InfoString_GetValue(string, "maxclients" , infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
+ info->gameversion = InfoString_GetValue(string, "gameversion", infostringvalue, sizeof(infostringvalue)) ? atoi(infostringvalue) : 0;
// count active players on server
// (we could gather more info, but we're just after the number)
}
if (length > 8 && !memcmp(string, "connect\\", 8))
{
- char *s;
client_t *client;
crypto_t *crypto = Crypto_ServerGetInstance(peeraddress);
string += 7;
}
else
{
- if ((s = InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue))))
+ if (InfoString_GetValue(string, "challenge", infostringvalue, sizeof(infostringvalue)))
{
// validate the challenge
for (i = 0;i < MAX_CHALLENGES;i++)
if(challenges[i].time > 0)
- if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, s))
+ if (!LHNETADDRESS_Compare(peeraddress, &challenges[i].address) && !strcmp(challenges[i].string, infostringvalue))
break;
// if the challenge is not recognized, drop the packet
if (i == MAX_CHALLENGES)
}
}
- if((s = InfoString_GetValue(string, "message", infostringvalue, sizeof(infostringvalue))))
- Con_DPrintf("Connecting client %s sent us the message: %s\n", addressstring2, s);
+ if(InfoString_GetValue(string, "message", infostringvalue, sizeof(infostringvalue)))
+ Con_DPrintf("Connecting client %s sent us the message: %s\n", addressstring2, infostringvalue);
if(!(islocal || sv_public.integer > -2))
{
}
// check engine protocol
- if(!(s = InfoString_GetValue(string, "protocol", infostringvalue, sizeof(infostringvalue))) || strcmp(s, "darkplaces 3"))
+ if(!InfoString_GetValue(string, "protocol", infostringvalue, sizeof(infostringvalue)) || strcmp(infostringvalue, "darkplaces 3"))
{
if (developer_extra.integer)
Con_Printf("Datagram_ParseConnectionless: sending \"reject Wrong game protocol.\" to %s.\n", addressstring2);