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 9C30B462A2 for ; Sun, 23 Feb 2025 22:41:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 843B1402DC; Sun, 23 Feb 2025 22:41:30 +0100 (CET) Received: from mail-wm1-f97.google.com (mail-wm1-f97.google.com [209.85.128.97]) by mails.dpdk.org (Postfix) with ESMTP id E9C34402CF for ; Sun, 23 Feb 2025 22:41:28 +0100 (CET) Received: by mail-wm1-f97.google.com with SMTP id 5b1f17b1804b1-43690d4605dso22763725e9.0 for ; Sun, 23 Feb 2025 13:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; t=1740346888; x=1740951688; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wcn35pJna9h3p7s3FpDOASY6Inc0i+PHwDk1fuGIRDI=; b=bPNxTMVJ0/71NBeS48NJ7mV5/Ag4VWhbj8Rku8xu0OPNGSLBOmR9IBJp6RNBs5z5pd cW3fDUuG7eq6obBs9KIellnM6wl1fV5qEVIsP+F+eMBUurIEuACTxTib/kempei2cGYO oNrEt6nyA1QOtXbdlDyPEvkYpATXGW+yBL6WPXUw+pJ3lwk77o1TGznbUyiYFwZy0soL cCsJy4bH18sJIIIFPhjpqsMjFHav7vayAI+t6D4iH9vs7LIt5fGVbQjqIWcTU2+WMhiT Sw5ML4x1+w55IDlsf/Mxl710xaseUcXVx2LIM1jNX4Yg3H4ogzDoumqfanFLNDSCDTzJ Y8nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740346888; x=1740951688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wcn35pJna9h3p7s3FpDOASY6Inc0i+PHwDk1fuGIRDI=; b=I0jAZCYlhe1Jr/ptl6F1DmYZC6RFDhsTGDMBNFo89itVjs92CxOdOmSHBHWcArq4X3 nIWfIshVbWndqeTC20xHDkxsR2ADUxWTvBzIokKK7q57hKWMcD9UEEeB3eoYI1d4O+53 63bImWbY4jFs8DMTrovos8FxSi7ngARLWeqYbKIM9r4DIfjF+sV3LMF+hWYfC+pOPoyw azhma2B3TGj34DeJPHvdTXcTyS+ptgzrj2CEmh2AicPIhK1xVYctH9Ff5B0PcBqJw1aw oU1CMw/7yI4QJswlT8SK5nOZpCGzvULXfKssm7HcAunjG8/c17uz49j+LaO2/0OCGq1u TlsA== X-Forwarded-Encrypted: i=1; AJvYcCW4zH7f8f5d1CKq1RP4z6EkzllsmpAYwdk6bvDXuDEiholzV5LdNTHFYRJTYtCUWb6Cr+mHuSA=@dpdk.org X-Gm-Message-State: AOJu0YymbUIpINhaWj8weiDW8htJRsHV9nkqUbFJixd3NKn+XO7s2V++ B73EArMIN6vr18P8BZKLEQgPMC9Ouneizdi6vrv2U+egwL3attO8A9Ka9bExjjAnIwdGoyDuZJ4 8n/sRNeVYYTos/MSEJWqFi85eWGl8feY9 X-Gm-Gg: ASbGncty6tcwGIAX3O4orFO/SM3AZHs6B1T2FlO8P3xK89BQE8wNB8Ls+PgnNnxT3Wo A1gXoPg6WYz1QwdO/T0ynTVTvCR7UoxP553ytOOjr/21uzJWlIzSyPvDJa78UBkkhj3Te3vO8Uc bvGHA8qmnKwRWhw3BDMFzqhenaXENiCTcDHXc2l6VCdj19b10MkHntRIUrNbzGtV+4+YGJuWtsa dJJDJOSTHe5oouSPMMgexMW7HEnUaYVLkgKc25rC5hdPOx9A0En5Nucvg+YLZJuKQ0HuecWy2Af TO57q/0n4N6p/F97PEDj9zN94dTUwjOJ+NdroBcybxBDNKil99E+42ZV6M62 X-Google-Smtp-Source: AGHT+IHT9AX1SMtu8PS5CE0AcbcN/WgmzjOlImWSnf4SiUAvMkv+TpxprnT0WhJyCCoDaGCrUDlF27yQVnhX X-Received: by 2002:a05:600c:3b93:b0:439:96b2:e9b with SMTP id 5b1f17b1804b1-439ae1e6a3amr75376745e9.9.1740346888461; Sun, 23 Feb 2025 13:41:28 -0800 (PST) Received: from smtpservice.6wind.com ([185.13.181.2]) by smtp-relay.gmail.com with ESMTP id 5b1f17b1804b1-439b037040fsm4997805e9.45.2025.02.23.13.41.28; Sun, 23 Feb 2025 13:41:28 -0800 (PST) X-Relaying-Domain: 6wind.com Received: from localhost (rainbow.dev.6wind.com [10.17.1.165]) by smtpservice.6wind.com (Postfix) with ESMTP id 5821D14EF6; Sun, 23 Feb 2025 22:41:28 +0100 (CET) From: Ariel Otilibili To: dev@dpdk.org Cc: Thomas Monjalon , David Marchand , Ariel Otilibili , Reshma Pattan , Stephen Hemminger , stable@dpdk.org Subject: [PATCH v2 1/1] pcapng: warn if NULL is passed to rte_pcapng_close Date: Sun, 23 Feb 2025 22:41:23 +0100 Message-Id: <20250223214123.447579-2-ariel.otilibili@6wind.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250223214123.447579-1-ariel.otilibili@6wind.com> References: <20250216160833.3216001-1-ariel.otilibili@6wind.com> <20250223214123.447579-1-ariel.otilibili@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org rte_pcapng_close() might dereference a null pointer; as example, PVS-Studio gives its usage in test_pcapng.c: indeed, that call to rte_pcapng_close() might receive a null pointer. In that case, rte_errno is set to EINVAL. The API is updated accordingly. Link: https://pvs-studio.com/en/docs/warnings/v522/ Link: https://github.com/DPDK/dpdk/blob/e5176f23ae8b31437c3e5eb875c81f95bf3a9942/app/test/test_pcapng.c#L438 Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files") Signed-off-by: Ariel Otilibili --- .mailmap | 2 +- lib/pcapng/rte_pcapng.c | 3 +++ lib/pcapng/rte_pcapng.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index a03d3cfb591b..ea68d6180ccc 100644 --- a/.mailmap +++ b/.mailmap @@ -135,7 +135,7 @@ Anupam Kapoor Apeksha Gupta Archana Muniganti Archit Pandey -Ariel Otilibili +Ariel Otilibili Arkadiusz Kubalewski Arkadiusz Kusztal Arnaud Fiorini diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 16485b27cb46..d2cbcea42885 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -716,6 +716,9 @@ rte_pcapng_fdopen(int fd, void rte_pcapng_close(rte_pcapng_t *self) { + if (!self) + rte_errno = EINVAL; + close(self->outfd); free(self); } diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h index 48f2b5756430..f7b976987320 100644 --- a/lib/pcapng/rte_pcapng.h +++ b/lib/pcapng/rte_pcapng.h @@ -60,6 +60,8 @@ rte_pcapng_fdopen(int fd, * * @param self * handle to library + + * If self is NULL, rte_errno is set to EINVAL. */ void rte_pcapng_close(rte_pcapng_t *self); -- 2.30.2