All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Don't pass NULL as src to memcpy, even when zero len.
@ 2019-10-28 19:42 Will Dietz
  2019-10-28 19:59 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Will Dietz @ 2019-10-28 19:42 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]

Skip the memcpy when len = 0, definitely don't ignore attempt
to copy X bytes from NULL where X != 0 :).
---
 monitor/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/monitor/main.c b/monitor/main.c
index 020dba86..41692cd1 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -176,7 +176,8 @@ static size_t rta_add(void *rta_buf, unsigned short type, uint16_t len,
 
 	rta->rta_len = rta_len;
 	rta->rta_type = type;
-	memcpy(RTA_DATA(rta), data, len);
+	if (len)
+		memcpy(RTA_DATA(rta), data, len);
 
 	return RTA_SPACE(len);
 }
-- 
2.24.0-rc1

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

* Re: [PATCH] Don't pass NULL as src to memcpy, even when zero len.
  2019-10-28 19:42 [PATCH] Don't pass NULL as src to memcpy, even when zero len Will Dietz
@ 2019-10-28 19:59 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2019-10-28 19:59 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 294 bytes --]

Hi Will,

On 10/28/19 2:42 PM, Will Dietz wrote:
> Skip the memcpy when len = 0, definitely don't ignore attempt
> to copy X bytes from NULL where X != 0 :).
> ---
>   monitor/main.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 

Applied, thanks.

Regards,
-Denis

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

end of thread, other threads:[~2019-10-28 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28 19:42 [PATCH] Don't pass NULL as src to memcpy, even when zero len Will Dietz
2019-10-28 19:59 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.