From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FD61C433FE for ; Tue, 21 Sep 2021 11:02:57 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 2AD466115A for ; Tue, 21 Sep 2021 11:02:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2AD466115A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8310740DF8; Tue, 21 Sep 2021 13:02:56 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 2A69340683 for ; Tue, 21 Sep 2021 13:02:55 +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 18L99EOo005194; Tue, 21 Sep 2021 04:02:54 -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=2Q8KTm5l74EKVnb0+Z43o8jI0ZyeQS5zrgQEXQnn6U4=; b=jFd12KS5UhlAsE6zF8XP+1bOZjX1vCLWOfoi8kbzp7RmPqE1vPLpuKP4Zz6HK+D8hy0Q pmvqf9fkoi02TM2VDNwMclJo+GNDmx8LInIebg1mTX4HjuQyBDKf3qgYvdMYckSm7/Tg 0wgRcgPu80VIxFE0d/OAF8OrDnzjQVi3mtZOkNs1QdByigV2t6Y7JJuWnk7MyiRdRCK5 Rl1bh46NmczHLuEf4lSkMsSvAtLf9Nx8EUYIJLTbZmtOUZ23gDIYE/9T2UyXw/ZGBxYR fFo33BGNUy20bzF+TsDL11vcOM4vfqBgBcMABltf69vONaPjZZp7qJh+BaqINTWy0+pJ Eg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3b7cgt893t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 21 Sep 2021 04:02:54 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 04:02:52 -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; Tue, 21 Sep 2021 04:02:52 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id A5D0F3F706B; Tue, 21 Sep 2021 04:02:51 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , Gowrishankar Muthukrishnan Date: Tue, 21 Sep 2021 16:32:43 +0530 Message-ID: <20210921110243.1919933-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <5a95b25b81e7ee57edfdcea73b9266bc8dae8d77.1631120194.git.gmuthukrishn@marvell.com> References: <5a95b25b81e7ee57edfdcea73b9266bc8dae8d77.1631120194.git.gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: ifVtT5D40908x5BitGBfDZViZ8VJqkxu X-Proofpoint-GUID: ifVtT5D40908x5BitGBfDZViZ8VJqkxu 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-21_01,2021-09-20_01,2020-04-07_01 Subject: [dpdk-dev] [v2] 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") v2: - split from series 18768 ("cnxk: enable telemetry endpoints"). Signed-off-by: Gowrishankar Muthukrishnan --- 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