DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/1] pcapng: fix null dereference in rte_pcapng_close
@ 2025-02-16 16:08 Ariel Otilibili
  2025-02-16 16:08 ` [PATCH 1/1] " Ariel Otilibili
  0 siblings, 1 reply; 3+ messages in thread
From: Ariel Otilibili @ 2025-02-16 16:08 UTC (permalink / raw)
  To: dev
  Cc: Thomas Monjalon, David Marchand, Ariel Otilibili, Reshma Pattan,
	Stephen Hemminger, stable

Hello,

This patch fixes a null dereference warning; it was found by static analysis, courtesy of Stephen Hemminger.

Thank you,

Ariel Otilibili (1):
  pcapng: fix null dereference in rte_pcapng_close

 .mailmap                | 2 +-
 lib/pcapng/rte_pcapng.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] pcapng: fix null dereference in rte_pcapng_close
  2025-02-16 16:08 [PATCH 0/1] pcapng: fix null dereference in rte_pcapng_close Ariel Otilibili
@ 2025-02-16 16:08 ` Ariel Otilibili
  2025-02-16 16:51   ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Ariel Otilibili @ 2025-02-16 16:08 UTC (permalink / raw)
  To: dev
  Cc: Thomas Monjalon, David Marchand, Ariel Otilibili, Reshma Pattan,
	Stephen Hemminger, stable

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.

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 <ariel.otilibili@6wind.com>
---
 .mailmap                | 2 +-
 lib/pcapng/rte_pcapng.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index a03d3cfb591b..ea68d6180ccc 100644
--- a/.mailmap
+++ b/.mailmap
@@ -135,7 +135,7 @@ Anupam Kapoor <anupam.kapoor@gmail.com>
 Apeksha Gupta <apeksha.gupta@nxp.com>
 Archana Muniganti <marchana@marvell.com> <muniganti.archana@caviumnetworks.com>
 Archit Pandey <architpandeynitk@gmail.com>
-Ariel Otilibili <otilibil@eurecom.fr> <ariel.otilibili@6wind.com>
+Ariel Otilibili <ariel.otilibili@6wind.com> <otilibil@eurecom.fr>
 Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
 Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
 Arnaud Fiorini <arnaud.fiorini@polymtl.ca>
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 16485b27cb46..efd96a16ede7 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)
+		return;
+
 	close(self->outfd);
 	free(self);
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] pcapng: fix null dereference in rte_pcapng_close
  2025-02-16 16:08 ` [PATCH 1/1] " Ariel Otilibili
@ 2025-02-16 16:51   ` Stephen Hemminger
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2025-02-16 16:51 UTC (permalink / raw)
  To: Ariel Otilibili
  Cc: dev, Thomas Monjalon, David Marchand, Reshma Pattan, stable

On Sun, 16 Feb 2025 17:08:33 +0100
Ariel Otilibili <ariel.otilibili@6wind.com> wrote:

> 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.
> 
> 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 <ariel.otilibili@6wind.com>

Not sure this is necessary.
The analgous function is fclose() and calling fclose() with NULL will crash.

I would rather update the documentation than silently ignore buggy programs.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-16 16:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-16 16:08 [PATCH 0/1] pcapng: fix null dereference in rte_pcapng_close Ariel Otilibili
2025-02-16 16:08 ` [PATCH 1/1] " Ariel Otilibili
2025-02-16 16:51   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).