Fix possible null pointer dereference in _client_clanmember_rankupdatereq() when packet_get_str_const() returns a null pointer
This commit is contained in:
parent
d7d6a192d9
commit
44d6c78ebf
1 changed files with 10 additions and 3 deletions
|
@ -4961,9 +4961,9 @@ namespace pvpgn
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((rpacket = packet_create(packet_class_bnet)) != NULL) {
|
||||
if ((rpacket = packet_create(packet_class_bnet)) != NULL)
|
||||
{
|
||||
int offset = sizeof(t_client_clanmember_rankupdate_req);
|
||||
const char *username;
|
||||
char status;
|
||||
t_clan *clan;
|
||||
t_clanmember *dest_member;
|
||||
|
@ -4974,7 +4974,14 @@ namespace pvpgn
|
|||
packet_set_type(rpacket, SERVER_CLANMEMBER_RANKUPDATE_REPLY);
|
||||
bn_int_set(&rpacket->u.server_clanmember_rankupdate_reply.count,
|
||||
bn_int_get(packet->u.client_clanmember_rankupdate_req.count));
|
||||
username = packet_get_str_const(packet, offset, MAX_USERNAME_LEN);
|
||||
const char* const username = packet_get_str_const(packet, offset, MAX_USERNAME_LEN);
|
||||
if (!username)
|
||||
{
|
||||
eventlog(eventlog_level_error, __FUNCTION__, "[{}] Could not retrieve username from CLANMEMBER_RANKUPDATE_REQ packet", conn_get_socket(c));
|
||||
packet_del_ref(rpacket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset += (std::strlen(username) + 1);
|
||||
if (packet_get_size(packet) < offset + 1)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue