json: fix wrong param in json_parse_ut.c calling function 'spdk_json_parse'

the sizeof(g_vals) should be the num of array, not the num of bytes. see follow:

CU_ASSERT(spdk_json_parse(g_buf, sizeof(in) - 1, g_vals, sizeof(g_vals), &g_end, flags | SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE) == num_vals);

Fixes #2623

Signed-off-by: tongkunkun <tongkunkun_yewu@cmss.chinamobile.com>
Change-Id: I3b7994606284fe3464650337ecb0f723a627f7aa
Reported-by: Jim Harris <james.r.harris@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13841
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
tongkunkun 2022-08-03 14:09:22 +08:00 committed by Tomasz Zawadzki
parent a02483e67c
commit c8583472bd

View File

@ -9,9 +9,11 @@
#include "json/json_parse.c"
#define JSONVALUE_NUM 100
static uint8_t g_buf[1000];
static void *g_end;
static struct spdk_json_val g_vals[100];
static struct spdk_json_val g_vals[JSONVALUE_NUM];
static int g_cur_val;
/* Fill buf with raw data */
@ -30,7 +32,7 @@ static int g_cur_val;
BUF_SETUP(in); \
CU_ASSERT(spdk_json_parse(g_buf, sizeof(in) - 1, NULL, 0, &g_end, flags) == num_vals); \
memset(g_vals, 0, sizeof(g_vals)); \
CU_ASSERT(spdk_json_parse(g_buf, sizeof(in) - 1, g_vals, sizeof(g_vals), &g_end, flags | SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE) == num_vals); \
CU_ASSERT(spdk_json_parse(g_buf, sizeof(in) - 1, g_vals, JSONVALUE_NUM, &g_end, flags | SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE) == num_vals); \
CU_ASSERT(g_end == g_buf + sizeof(in) - sizeof(trailing)); \
CU_ASSERT(memcmp(g_end, trailing, sizeof(trailing) - 1) == 0); \
g_cur_val = 0