--- libaitrpc/src/srv.c 2024/03/20 17:06:11 1.30.2.12 +++ libaitrpc/src/srv.c 2025/03/31 12:21:07 1.33 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.30.2.12 2024/03/20 17:06:11 misho Exp $ +* $Id: srv.c,v 1.33 2025/03/31 12:21:07 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2024 +Copyright 2004 - 2025 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -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); @@ -1562,7 +1562,7 @@ rpc_srv_initServer(u_char InstID, int concurentClients /* init functions */ pthread_mutex_init(&srv->srv_funcs.mtx, NULL); SLIST_INIT(&srv->srv_funcs); - AVL_INIT(&srv->srv_funcs); + RB_INIT(&srv->srv_funcs); /* init scheduler */ srv->srv_root = schedBegin(); @@ -1722,7 +1722,7 @@ rpc_srv_loopServer(rpc_srv_t * __restrict srv) AIT_FREE_VAL(&f->func_name); e_free(f); } - srv->srv_funcs.avlh_root = NULL; + srv->srv_funcs.rbh_root = NULL; RPC_FUNCS_UNLOCK(&srv->srv_funcs); return 0; @@ -1822,7 +1822,7 @@ rpc_srv_initServer2(u_char InstID, int concurentClient /* init functions */ pthread_mutex_init(&srv->srv_funcs.mtx, NULL); SLIST_INIT(&srv->srv_funcs); - AVL_INIT(&srv->srv_funcs); + RB_INIT(&srv->srv_funcs); /* init scheduler */ srv->srv_root = schedBegin(); @@ -1940,7 +1940,7 @@ rpc_srv_initServerExt(u_char InstID, int netBuf, int f /* init functions */ pthread_mutex_init(&srv->srv_funcs.mtx, NULL); SLIST_INIT(&srv->srv_funcs); - AVL_INIT(&srv->srv_funcs); + RB_INIT(&srv->srv_funcs); /* init scheduler */ srv->srv_root = schedBegin();