From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id B020DA05D3 for ; Tue, 23 Apr 2019 18:48:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 109211B4C1; Tue, 23 Apr 2019 18:48:33 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 8042E1B3D2 for ; Tue, 23 Apr 2019 18:48:26 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id k19so7900039pgh.0 for ; Tue, 23 Apr 2019 09:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AZKQ2K/OWD0zBctfqE7pT9svK7y8AYM7fapDXeko9Fg=; b=F/Tx698uCyj5vxKDl9sqD5zhzSFFbsd8/932tU2OASghw80CxAYRldPdTyl8XGl3JM yg2jDwvWMHzVtDkkUEINE14WiX+S8tk8gIy/Q05dVtIuAmJ3YvCkdDB16NGE6BoN84ZI 3+FRzKbRf7ysbx9tN/SvoLmDZbgsaizBjMS6phGUBwpVp9WzL2g0Kc2GN/xeEZ/87Xz/ whix5LEQ3Qu7fYruWFtZRdO5pq+bj9VK2bQDWRK3NP3r1PWhuQlWQpv+tU5ZRiWDDhuz JMH1O/R3v1KGj/RWe2b0EhUKflZ6A40NWCAK25VU7rItwN66Id9c/VUutIBkBPlDQduz 09qA== 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:mime-version:content-transfer-encoding; bh=AZKQ2K/OWD0zBctfqE7pT9svK7y8AYM7fapDXeko9Fg=; b=hPKjAcRh1t+WckVUvh3slyUmk+jiyr1euHw4tQyP6bjfkA56g0VqUjGknjaqfgImeC fZkdCfVqVsgYzuJ9IzTCzo4zkTgBov11VWzBVJaGSdwPDyjMBzGC2UBu4aZ0w/RUz+nU /qDMn9MSLXPZ2jeHKtAYCCLNxtNqmBb3TstBDpvFCfHfCAfu9nn4WoUCX+FE04NcUJ88 fSAHuFLDo7r0LwWQkRQgv2NHRrdzlj4lNNX150Vn3DNdEaOw1HnsXERCK3qgx0ggB6Iy mCTvw0+gPFox+OJgCpM22r8ZBuh2M42NpHq0V0bWqy19Di1RE9MWHKIVsoeEKi0ylHZO zjIQ== X-Gm-Message-State: APjAAAVEmmkudcwG/BzeD97UqYwoadSvoj2oSvrkDgMTqMh4ha63cx4h m/axEvZFAXTbsCGhzrO8foM9sw== X-Google-Smtp-Source: APXvYqz8a1dTcQaCohDqg83/qDzN1Q8Js197jZLeOnDKHD3a9dBbi28l4zmaxX7lCkMmEHBVul+nvQ== X-Received: by 2002:aa7:8694:: with SMTP id d20mr27465041pfo.81.1556038105604; Tue, 23 Apr 2019 09:48:25 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h65sm58943277pfd.108.2019.04.23.09.48.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 09:48:24 -0700 (PDT) From: Stephen Hemminger To: bruce.richardson@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 23 Apr 2019 09:48:12 -0700 Message-Id: <20190423164812.3427-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423164812.3427-1-stephen@networkplumber.org> References: <20190423164812.3427-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 4/4] net/ring: check length of ring name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190423164812.HiO18IFu4q34gyFthpevSTB0uHHFLLnontzD_rkgp8Q@z> The ring name is passed in as part of this drivers API, but it doesn't check that the name is not truncated. Signed-off-by: Stephen Hemminger --- drivers/net/ring/rte_eth_ring.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 0355f2b7c4d8..9125692f2c9b 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -383,7 +383,12 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], snprintf(args_str, sizeof(args_str), "%s=%p", ETH_RING_INTERNAL_ARG, &args); - snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); + + ret = snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); + if (ret >= (int)sizeof(ring_name)) { + rte_errno = ENAMETOOLONG; + return -1; + } ret = rte_vdev_init(ring_name, args_str); if (ret) { @@ -417,7 +422,15 @@ eth_dev_ring_create(const char *name, const unsigned int numa_node, RTE_PMD_RING_MAX_TX_RINGS); for (i = 0; i < num_rings; i++) { - snprintf(rng_name, sizeof(rng_name), "ETH_RXTX%u_%s", i, name); + int cc; + + cc = snprintf(rng_name, sizeof(rng_name), + "ETH_RXTX%u_%s", i, name); + if (cc >= (int)sizeof(rng_name)) { + rte_errno = ENAMETOOLONG; + return -1; + } + rxtx[i] = (action == DEV_CREATE) ? rte_ring_create(rng_name, 1024, numa_node, RING_F_SP_ENQ|RING_F_SC_DEQ) : -- 2.20.1