--- libaitrpc/src/srv.c 2024/03/20 17:32:31 1.31 +++ libaitrpc/src/srv.c 2024/10/29 01:33:17 1.32 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.31 2024/03/20 17:32:31 misho Exp $ +* $Id: srv.c,v 1.32 2024/10/29 01:33:17 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -543,7 +543,7 @@ rxUDPPacket(sched_task_t *task) #endif rlen = recvfrom(TASK_FD(task), AIT_GET_BUF(&b), AIT_LEN(&b), 0, &sa.sa, &salen); rpc = (struct tagRPCCall*) AIT_GET_BUF(&b); - if (rlen < sizeof(struct tagRPCCall)) + if (!rpc || rlen < sizeof(struct tagRPCCall)) goto end; else len = ntohl(rpc->call_len); @@ -687,7 +687,7 @@ rxRAWPacket(sched_task_t *task) if (sa.sa.sa_family == AF_INET) { struct ip *h; h = (struct ip*) AIT_GET_BUF(&b); - if (rlen < ntohs(h->ip_len) || h->ip_p != IPPROTO_ERPC) + if (!h || rlen < ntohs(h->ip_len) || h->ip_p != IPPROTO_ERPC) goto end; else { rlen -= sizeof(struct ip); @@ -697,7 +697,7 @@ rxRAWPacket(sched_task_t *task) #ifdef IPV6_REMOVE_HEADER struct ip6_hdr *h; h = (struct ip6_hdr*) AIT_GET_BUF(&b); - if (rlen < ntohs(h->ip6_plen) || h->ip6_nxt != IPPROTO_ERPC) + if (!h || rlen < ntohs(h->ip6_plen) || h->ip6_nxt != IPPROTO_ERPC) goto end; else { rlen -= sizeof(struct ip6_hdr); @@ -707,7 +707,7 @@ rxRAWPacket(sched_task_t *task) rpc = (struct tagRPCCall*) AIT_GET_BUF(&b); #endif } - if (rlen < sizeof(struct tagRPCCall)) + if (!rpc || rlen < sizeof(struct tagRPCCall)) goto end; else len = ntohl(rpc->call_len); @@ -1014,7 +1014,7 @@ rxEXTPacket(sched_task_t *task) AIT_SET_BUF(&b, NULL, srv->srv_netbuf); rlen = read(TASK_FD(task), AIT_GET_BUF(&b), AIT_LEN(&b)); rpc = (struct tagRPCCall*) AIT_GET_BUF(&b); - if (rlen < sizeof(struct tagRPCCall)) + if (!rpc || rlen < sizeof(struct tagRPCCall)) goto end; else len = ntohl(rpc->call_len);