public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arch: tile: gxio: mpipe.c:  Cleaning up missing null-terminate in conjunction with strncpy
@ 2014-07-26 14:03 Rickard Strandqvist
  2014-08-05 20:24 ` Chris Metcalf
  0 siblings, 1 reply; 11+ messages in thread
From: Rickard Strandqvist @ 2014-07-26 14:03 UTC (permalink / raw)
  To: Chris Metcalf, David S. Miller; +Cc: Rickard Strandqvist, linux-kernel

Replacing strncpy with strlcpy to avoid strings that lacks null terminate.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 arch/tile/gxio/mpipe.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/tile/gxio/mpipe.c b/arch/tile/gxio/mpipe.c
index 5301a9f..4f1eefb 100644
--- a/arch/tile/gxio/mpipe.c
+++ b/arch/tile/gxio/mpipe.c
@@ -511,8 +511,7 @@ int gxio_mpipe_link_instance(const char *link_name)
 	if (!context)
 		return GXIO_ERR_NO_DEVICE;
 
-	strncpy(name.name, link_name, sizeof(name.name));
-	name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
+	strlcpy(name.name, link_name, sizeof(name.name));
 
 	return gxio_mpipe_info_instance_aux(context, name);
 }
@@ -529,7 +528,7 @@ int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
 
 	rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac);
 	if (rv >= 0) {
-		strncpy(link_name, name.name, sizeof(name.name));
+		strlcpy(link_name, name.name, sizeof(name.name));
 		memcpy(link_mac, mac.mac, sizeof(mac.mac));
 	}
 
@@ -545,8 +544,7 @@ int gxio_mpipe_link_open(gxio_mpipe_link_t *link,
 	_gxio_mpipe_link_name_t name;
 	int rv;
 
-	strncpy(name.name, link_name, sizeof(name.name));
-	name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
+	strlcpy(name.name, link_name, sizeof(name.name));
 
 	rv = gxio_mpipe_link_open_aux(context, name, flags);
 	if (rv < 0)
-- 
1.7.10.4


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

end of thread, other threads:[~2014-08-29 18:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-26 14:03 [PATCH] arch: tile: gxio: mpipe.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
2014-08-05 20:24 ` Chris Metcalf
2014-08-05 21:25   ` Rickard Strandqvist
2014-08-06 18:16     ` [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio Chris Metcalf
2014-08-06 21:14       ` Rickard Strandqvist
2014-08-07  6:43       ` Randy Dunlap
2014-08-07 16:01         ` new generic strscpy API? (was Re: [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio) Chris Metcalf
2014-08-11 20:43         ` [PATCH v2] tile: avoid errors from truncating long strings in mpipe gxio Rickard Strandqvist
2014-08-11 21:30           ` Randy Dunlap
2014-08-29 18:31             ` [PATCH 1/2] Add strscpy() as a new string copy primitive Chris Metcalf
2014-08-29 18:34             ` [PATCH 2/2] tile gxio mpipe: use the new strscpy() primitive Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox