api: verify message size on receipt
When a message is received, verify that it's sufficiently large to accomodate any VLAs within message. To do that, we need a way to calculate message size including any VLAs. This patch adds such funcionality to vppapigen and necessary C code to use those to validate message size on receipt. Drop messages which are malformed. Type: improvement Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I2903aa21dee84be6822b064795ba314de46c18f4
This commit is contained in:

committed by
Ole Tr�an

parent
755042dec0
commit
9b7e8acf79
@ -64,6 +64,10 @@
|
||||
#include <vlibmemory/memclnt.api.h>
|
||||
#undef vl_endianfun
|
||||
|
||||
#define vl_calcsizefun
|
||||
#include <vlibmemory/memclnt.api.h>
|
||||
#undef vl_calcsizefun
|
||||
|
||||
/* instantiate all the print functions we know about */
|
||||
#if VPP_API_TEST_BUILTIN == 0
|
||||
#define vl_print(handle, ...)
|
||||
@ -2737,11 +2741,11 @@ void
|
||||
vat_api_hookup (vat_main_t * vam)
|
||||
{
|
||||
#define _(N, n) \
|
||||
vl_msg_api_set_handlers (VL_API_##N + 1, #n, vl_api_##n##_t_handler_uni, \
|
||||
vl_noop_handler, vl_api_##n##_t_endian, \
|
||||
vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 1, \
|
||||
vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \
|
||||
vl_api_##n##_t_fromjson);
|
||||
vl_msg_api_set_handlers ( \
|
||||
VL_API_##N + 1, #n, vl_api_##n##_t_handler_uni, vl_noop_handler, \
|
||||
vl_api_##n##_t_endian, vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 1, \
|
||||
vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \
|
||||
vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size);
|
||||
foreach_vpe_api_reply_msg;
|
||||
#if VPP_API_TEST_BUILTIN == 0
|
||||
foreach_standalone_reply_msg;
|
||||
|
Reference in New Issue
Block a user