diff --git a/daemon/kernel.c b/daemon/kernel.c index bde98b16b..5f416a59d 100644 --- a/daemon/kernel.c +++ b/daemon/kernel.c @@ -75,7 +75,24 @@ static int kernel_open_table(unsigned int id) { return -1; cmd.cmd = REMG_NOOP; - cmd.noop.last_cmd = __REMG_LAST; + + cmd.noop = (struct rtpengine_noop_info) { + .last_cmd = __REMG_LAST, + .msg_size = { + [REMG_NOOP] = sizeof(struct rtpengine_command_noop), + [REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target), + [REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target), + [REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination), + [REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call), + [REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call), + [REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream), + [REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream), + [REMG_PACKET] = sizeof(struct rtpengine_command_packet), + [REMG_GET_STATS] = sizeof(struct rtpengine_command_stats), + [REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats), + }, + }; + i = write(fd, &cmd, sizeof(cmd)); if (i <= 0) goto fail; diff --git a/kernel-module/xt_RTPENGINE.c b/kernel-module/xt_RTPENGINE.c index 425ff1980..b98fe129c 100644 --- a/kernel-module/xt_RTPENGINE.c +++ b/kernel-module/xt_RTPENGINE.c @@ -3550,6 +3550,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub enum rtpengine_command cmd; char scratchbuf[512]; size_t readlen, writelen, writeoffset; + int i; union { struct rtpengine_command_noop *noop; @@ -3625,6 +3626,9 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub case REMG_NOOP: if (msg.noop->noop.last_cmd != __REMG_LAST) err = -ERANGE; + for (i = 0; i < __REMG_LAST; i++) + if (msg.noop->noop.msg_size[i] != min_req_sizes[i]) + err = -EMSGSIZE; break; case REMG_ADD_TARGET: diff --git a/kernel-module/xt_RTPENGINE.h b/kernel-module/xt_RTPENGINE.h index 729390fec..49794ea82 100644 --- a/kernel-module/xt_RTPENGINE.h +++ b/kernel-module/xt_RTPENGINE.h @@ -174,10 +174,6 @@ struct rtpengine_stats_info { struct rtpengine_ssrc_stats ssrc_stats[RTPE_NUM_SSRC_TRACKING]; }; -struct rtpengine_noop_info { - int last_cmd; -}; - enum rtpengine_command { REMG_NOOP = 1, REMG_ADD_TARGET, @@ -194,6 +190,11 @@ enum rtpengine_command { __REMG_LAST }; +struct rtpengine_noop_info { + int last_cmd; + size_t msg_size[__REMG_LAST]; +}; + struct rtpengine_command_noop { enum rtpengine_command cmd; struct rtpengine_noop_info noop;