All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] serial-uclass.c: Copy at most sdev.name - 1 characters into the buffer
@ 2015-12-08  3:26 Tom Rini
  2015-12-08  3:26 ` [U-Boot] [PATCH 2/3] sandbox: eth-raw-os.c: Ensure that our interface name is not too long Tom Rini
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Tom Rini @ 2015-12-08  3:26 UTC (permalink / raw)
  To: u-boot

Coverity notes that we do not ensure a NULL terminated string here as we
could fill the entire buffer with our strncpy call.  Fix this by
subtracting one.

Reported-by: Coverity (CID 131093)
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 drivers/serial/serial-uclass.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 842f78b..2ef82b0 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -324,7 +324,7 @@ static int serial_post_probe(struct udevice *dev)
 		return 0;
 	memset(&sdev, '\0', sizeof(sdev));
 
-	strncpy(sdev.name, dev->name, sizeof(sdev.name));
+	strncpy(sdev.name, dev->name, sizeof(sdev.name) - 1);
 	sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
 	sdev.priv = dev;
 	sdev.putc = serial_stub_putc;
-- 
1.7.9.5

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

end of thread, other threads:[~2015-12-19 22:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08  3:26 [U-Boot] [PATCH 1/3] serial-uclass.c: Copy at most sdev.name - 1 characters into the buffer Tom Rini
2015-12-08  3:26 ` [U-Boot] [PATCH 2/3] sandbox: eth-raw-os.c: Ensure that our interface name is not too long Tom Rini
2015-12-08 19:35   ` Simon Glass
2015-12-19 22:23     ` Simon Glass
2015-12-08  3:26 ` [U-Boot] [PATCH 3/3] sandbox: sandbox_flash.c: Ensure NUL-termination on product/vendor strings Tom Rini
2015-12-08 19:35   ` Simon Glass
2015-12-08 23:28     ` Tom Rini
2015-12-08 23:42       ` Simon Glass
2015-12-08 23:58         ` Tom Rini
2015-12-09 23:58           ` Simon Glass
2015-12-10  1:01             ` Tom Rini
2015-12-08 19:35 ` [U-Boot] [PATCH 1/3] serial-uclass.c: Copy at most sdev.name - 1 characters into the buffer Simon Glass
2015-12-08 23:32   ` Tom Rini

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.