From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1DB8BA0C5C; Wed, 8 Sep 2021 19:04:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B106B4115F; Wed, 8 Sep 2021 19:03:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 20CE440E25 for ; Wed, 8 Sep 2021 19:03:39 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1889U311031640; Wed, 8 Sep 2021 10:03:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=fjKTdMuNSupIJnNLPZj/CXfUFAFzqBcavyDQXWDdYAs=; b=DT7ras0CtKl7RWRcExTX6Mk+iDg7p1UdiZWdJuXtu8923QDRKP6oyItu1a+3dPj5QQ7f RJY3uP6AKDj51qF1Gb5kR68xkMyL+o0B6DujfLSvFPul5C/XOCgGPRVebTOV2kWgzHpg SORBR5y41xAjFBuNu4NY48ZT3NZ5dD9g8UoPGfRwcl0cI3FoZ42QrjVc8KqJ1weG1896 UyNw6xFvI9NgGOQCSrd6NcXGEPBw7nGFVuxrGq5KcgCeUpk9lNatssU6DlAJino98uSh JYrqArxETJ74LOZDGwG/OF8wWBGhzdZKp1NaMV9oEPUY8XPl39/zhtODwm7TlQh+BLF7 TA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3axtka9vra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 08 Sep 2021 10:03:39 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 8 Sep 2021 10:03:37 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 8 Sep 2021 10:03:37 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id DD27E3F70C6; Wed, 8 Sep 2021 10:03:33 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , , , , , , , , , , , , Gowrishankar Muthukrishnan Date: Wed, 8 Sep 2021 22:33:07 +0530 Message-ID: <5a95b25b81e7ee57edfdcea73b9266bc8dae8d77.1631120194.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 2LB2AGu8PySMZzZjsFurVzCw99t_RSVL X-Proofpoint-ORIG-GUID: 2LB2AGu8PySMZzZjsFurVzCw99t_RSVL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-08_06,2021-09-07_02,2020-04-07_01 Subject: [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fix json output buffer size for a single largest value. Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON") Signed-off-by: Gowrishankar Muthukrishnan Change-Id: Ida314114b654b5085244a659eb08b22969339856 --- lib/telemetry/telemetry_json.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index ad270b9b30..ba2fde34cb 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -9,6 +9,7 @@ #include #include #include +#include /** * @file @@ -23,13 +24,15 @@ * @internal * Copies a value into a buffer if the buffer has enough available space. * Nothing written to buffer if an overflow ocurs. - * This function is not for use for values larger than 1k. + * Size of buffer is (single largest value - 6), where at least 6 chars + * would have been used for creating json dict i.e '{"x": ... }'. + * This function is not for use for values larger than this buffer size. */ __rte_format_printf(3, 4) static inline int __json_snprintf(char *buf, const int len, const char *format, ...) { - char tmp[1024]; + char tmp[RTE_TEL_MAX_SINGLE_STRING_LEN - 6]; va_list ap; int ret; -- 2.25.1