From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f46.google.com (mail-pg0-f46.google.com [74.125.83.46]) by dpdk.org (Postfix) with ESMTP id B409D7D15 for ; Mon, 21 Aug 2017 11:33:28 +0200 (CEST) Received: by mail-pg0-f46.google.com with SMTP id u191so22446315pgc.2 for ; Mon, 21 Aug 2017 02:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CtovoNEy/cDEzoUT6y+cAD6Zrsa6rwt0LQL15N86D5E=; b=SDshFFO1GD6SCLHyQ6HVwA9R/wJix+4iQzU1hUappf9X8lFaB2hJoP/uAXEA7+XY2z UIT1aoaUtAZ+dnu+nNYHy+eYdFGNxRwGZ4dFbxAmcHEXL10Jic+h2KoOGZO8QGScXlEm lgNNYgwQtfl28GPcXZ+azBWQHq8DUNeKTxdpzsWgOTXQ2w21KMyX5MCWPUsih7UusSF/ l4CkE2MonpWqPKNmrpQREZVoVD46BcY+sH4x5QbXKe6UYNHcT0ZZUHaw0y7p1peR1uw1 zviA8Xen+Yvev3s3PgnR/Ep5qYXyneIPUqT0lQd9n2Mkx24D2wnI9a65prZXSs5FNzVk XWHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CtovoNEy/cDEzoUT6y+cAD6Zrsa6rwt0LQL15N86D5E=; b=X+FtpzDJWmfZp7aXjmpf++yZhlq0Qv6MoQ39KEH/RKXvU3xQr0yn8LrtvkaTdk3q1v THwUV2pFx25X5tTHkSlaG6Si6uK0GADKlljc7yrBH/v9pWP83OccHFbTUfWj/1VhRep/ fkU1jb4Lf1FVxjcaalba3BZiEJNx3+Kmdx1hJ3VKDsjlNe1dSmfBwpVYWqo2a4OWjZ6I L8mFAx2DCRQxbVzKWkb8bv+qN+HaX2Vf37stLSMJSrC84y9YvVvCn7GFcZjEP/viE3kV 6qRU9GUxehsWrtDGO3icpXQt5PbU4xIwYXDLptXeBQkRqRcr86EWzwKtHETANf9CWe7G Dmiw== X-Gm-Message-State: AHYfb5gPQxO3rRZg6W1cksH5tgYEA95mVAcep/3TQl9n4yNOIC8egI+z Jh06GNEfY1UP1TpY X-Received: by 10.99.181.77 with SMTP id u13mr15925070pgo.262.1503308008056; Mon, 21 Aug 2017 02:33:28 -0700 (PDT) Received: from localhost.localdomain ([45.63.61.64]) by smtp.gmail.com with ESMTPSA id 69sm23355087pfh.186.2017.08.21.02.33.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Aug 2017 02:33:26 -0700 (PDT) From: Yuanhan Liu To: Remy Horton Cc: dpdk stable , Yuanhan Liu Date: Mon, 21 Aug 2017 17:30:19 +0800 Message-Id: <1503307878-16728-5-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503307878-16728-1-git-send-email-yliu@fridaylinux.org> References: <1503307878-16728-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'metrics: fix name string termination' has been queued to stable release 17.05.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 09:33:29 -0000 Hi, FYI, your patch has been queued to stable release 17.05.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/24/17. So please shout if anyone has objections. Thanks. --yliu --- >>From a7dd0ca5c8ba450e981892a5d40eb5126ae65b37 Mon Sep 17 00:00:00 2001 From: Remy Horton Date: Tue, 18 Jul 2017 10:43:47 +0100 Subject: [PATCH] metrics: fix name string termination [ upstream commit fa43ac77294a1a00b1fc30514162145ca17fa766 ] The public API (struct rte_metric_name) includes the NULL terminator byte in RTE_METRICS_MAX_NAME_LENGTH but the library itself internally excludes it. This makes it possible for an application to receive an unterminated name string. Fix be enforcing the NULL termination of all name strings to the length that the public API expects. Fixes: 349950ddb9c5 ("metrics: add information metrics library") Signed-off-by: Remy Horton --- lib/librte_metrics/rte_metrics.c | 2 ++ lib/librte_metrics/rte_metrics.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c index e9a122c..dbbad32 100644 --- a/lib/librte_metrics/rte_metrics.c +++ b/lib/librte_metrics/rte_metrics.c @@ -144,6 +144,8 @@ rte_metrics_reg_names(const char * const *names, uint16_t cnt_names) entry = &stats->metadata[idx_name + stats->cnt_stats]; strncpy(entry->name, names[idx_name], RTE_METRICS_MAX_NAME_LEN); + /* Enforce NULL-termination */ + entry->name[RTE_METRICS_MAX_NAME_LEN - 1] = '\0'; memset(entry->value, 0, sizeof(entry->value)); entry->idx_next_stat = idx_name + stats->cnt_stats + 1; } diff --git a/lib/librte_metrics/rte_metrics.h b/lib/librte_metrics/rte_metrics.h index 0fa3104..297300a 100644 --- a/lib/librte_metrics/rte_metrics.h +++ b/lib/librte_metrics/rte_metrics.h @@ -118,7 +118,8 @@ void rte_metrics_init(int socket_id); * is required for updating said metric's value. * * @param name - * Metric name + * Metric name. If this exceeds RTE_METRICS_MAX_NAME_LEN (including + * the NULL terminator), it is truncated. * * @return * - Zero or positive: Success (index key of new metric) -- 2.7.4