mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
make local command ip address checking sane
This commit is contained in:
parent
e148880ec6
commit
8fdd8a0888
4 changed files with 10 additions and 4 deletions
|
@ -51,6 +51,7 @@ typedef struct
|
|||
} netadr_t;
|
||||
|
||||
extern netadr_t net_local_adr;
|
||||
extern netadr_t net_loopback_adr;
|
||||
extern netadr_t net_from; // address of who sent the packet
|
||||
extern struct msg_s *net_message;
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
|
||||
int net_socket;
|
||||
netadr_t net_local_adr;
|
||||
netadr_t net_loopback_adr;
|
||||
netadr_t net_from;
|
||||
|
||||
static sizebuf_t _net_message_message;
|
||||
|
@ -418,6 +419,9 @@ NET_Init (int port)
|
|||
// determine my name & address
|
||||
NET_GetLocalAddress ();
|
||||
|
||||
net_loopback_adr.ip[0] = 127;
|
||||
net_loopback_adr.ip[3] = 1;
|
||||
|
||||
Con_Printf ("UDP (IPv4) Initialized\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -550,6 +550,8 @@ NET_Init (int port)
|
|||
// determine my name & address
|
||||
NET_GetLocalAddress ();
|
||||
|
||||
net_loopback_adr.ip[15] = 1;
|
||||
|
||||
Con_Printf ("UDP (IPv6) Initialized\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -861,10 +861,9 @@ CL_ConnectionlessPacket (void)
|
|||
|
||||
Con_Printf ("client command\n");
|
||||
|
||||
if (!cl_allow_cmd_pkt->int_val ||
|
||||
((*(unsigned int *) net_from.ip !=
|
||||
*(unsigned int *) net_local_adr.ip &&
|
||||
*(unsigned int *) net_from.ip != htonl (INADDR_LOOPBACK)))) {
|
||||
if (!cl_allow_cmd_pkt->int_val
|
||||
|| !NET_CompareBaseAdr (net_from, net_local_adr)
|
||||
|| !NET_CompareBaseAdr (net_from, net_loopback_adr)) {
|
||||
Con_Printf ("Command packet from remote host. Ignored.\n");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue