mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Updated how router thread checks packet sizes, cleaned up code
This commit is contained in:
parent
42b3f7ce13
commit
53346c2536
@ -305,18 +305,10 @@ static DWORD WINAPI router_main(LPVOID buf) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(rval < sizeof(ipx_packet)) {
|
||||
debug("Recieved undersized packet, discarding");
|
||||
continue;
|
||||
}
|
||||
|
||||
packet->dest_socket = ntohs(packet->dest_socket);
|
||||
packet->src_socket = ntohs(packet->src_socket);
|
||||
packet->size = ntohs(packet->size);
|
||||
|
||||
/* Prevent buffer overflows */
|
||||
if(packet->size > MAX_PACKET_SIZE) {
|
||||
debug("Recieved oversized packet, discarding");
|
||||
if(packet->size > MAX_PACKET_SIZE || packet->size+sizeof(ipx_packet)-1 != rval) {
|
||||
debug("Recieved packet with incorrect size field, discarding");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -325,6 +317,10 @@ static DWORD WINAPI router_main(LPVOID buf) {
|
||||
add_host(packet->src_net, packet->src_node, ntohl(addr.sin_addr.s_addr));
|
||||
|
||||
for(sockptr = sockets; sockptr; sockptr = sockptr->next) {
|
||||
/* TODO: Don't require IPX_BROADCAST for recieving broadcast packets
|
||||
* (Make it optional? It was a bug in win95.)
|
||||
*/
|
||||
|
||||
if(
|
||||
sockptr->flags & IPX_BOUND &&
|
||||
sockptr->flags & IPX_RECV &&
|
||||
|
@ -50,21 +50,6 @@
|
||||
(ptr)->socket = 0;\
|
||||
(ptr)->next = NULL;
|
||||
|
||||
#define INIT_PACKET(ptr) \
|
||||
(ptr)->ptype = 0;\
|
||||
memset((ptr)->dest_net, 0, 4);\
|
||||
memset((ptr)->dest_node, 0, 6);\
|
||||
(ptr)->dest_socket = 0;\
|
||||
memset((ptr)->src_net, 0, 4);\
|
||||
memset((ptr)->src_node, 0, 6);\
|
||||
(ptr)->src_socket = 0;\
|
||||
(ptr)->size = 0;
|
||||
|
||||
#define INIT_HOST(ptr) \
|
||||
memset((ptr)->hwaddr, 0, 6);\
|
||||
(ptr)->ipaddr = 0;\
|
||||
(ptr)->next = NULL;
|
||||
|
||||
#define RETURN(...) \
|
||||
unlock_mutex();\
|
||||
return __VA_ARGS__;
|
||||
|
@ -642,7 +642,6 @@ int WSAAPI sendto(SOCKET fd, const char *buf, int len, int flags, const struct s
|
||||
RETURN_WSA(ERROR_OUTOFMEMORY, -1);
|
||||
}
|
||||
|
||||
INIT_PACKET(packet);
|
||||
packet->ptype = sockptr->s_ptype;
|
||||
|
||||
memcpy(packet->dest_net, ipxaddr->sa_netnum, 4);
|
||||
|
Loading…
x
Reference in New Issue
Block a user