diff --git a/fastrpc/listener.c b/fastrpc/listener.c index 10d3a46..d551ae9 100644 --- a/fastrpc/listener.c +++ b/fastrpc/listener.c @@ -19,6 +19,7 @@ * along with this program. If not, see . */ +#include #include #include "fastrpc.h" @@ -29,6 +30,9 @@ const struct fastrpc_interface *fastrpc_listener_interfaces[] = { }; +size_t fastrpc_listener_n_interfaces = sizeof(fastrpc_listener_interfaces) + / sizeof(*fastrpc_listener_interfaces); + static int adsp_listener_init2(int fd) { return fastrpc2(&adsp_listener_init2_def, fd, ADSP_LISTENER_HANDLE); @@ -192,8 +196,7 @@ static int invoke_requested_procedure(uint32_t handle, uint8_t out_count; int ret; - if (handle >= sizeof(fastrpc_listener_interfaces) - / sizeof(*fastrpc_listener_interfaces) + if (handle >= fastrpc_listener_n_interfaces || REMOTE_SCALARS_METHOD(sc) >= fastrpc_listener_interfaces[handle]->n_procs) return -1; diff --git a/fastrpc/listener.h b/fastrpc/listener.h index fef0379..c8262b5 100644 --- a/fastrpc/listener.h +++ b/fastrpc/listener.h @@ -1,6 +1,8 @@ #ifndef LISTENER_H #define LISTENER_H +#include + #include "fastrpc.h" #include "iobuffer.h" @@ -17,6 +19,7 @@ struct fastrpc_interface { }; extern const struct fastrpc_interface *fastrpc_listener_interfaces[]; +extern size_t fastrpc_listener_n_interfaces; int run_fastrpc_listener(int fd);