From 10ec4737c2870b96b52e65b7e5857b131f048360 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 4 Jul 2015 15:20:36 -0600 Subject: [PATCH] Use strncpy instead of strcpy in uname() --- libc/misc/lib_utsname.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc/misc/lib_utsname.c b/libc/misc/lib_utsname.c index 7b43817004..03f3796ca8 100644 --- a/libc/misc/lib_utsname.c +++ b/libc/misc/lib_utsname.c @@ -80,7 +80,7 @@ int uname(FAR struct utsname *name) { int ret = 1; - strcpy(name->sysname, "NuttX"); + strncpy(name->sysname, "NuttX", SYS_NAMELEN); #ifdef CONFIG_NET /* Get the hostname */ @@ -94,9 +94,9 @@ int uname(FAR struct utsname *name) strcpy(name->nodename, ""); #endif - strcpy(name->release, CONFIG_VERSION_STRING); - strcpy(name->version, CONFIG_VERSION_BUILD); - strcpy(name->machine, CONFIG_ARCH); + strncpy(name->release, CONFIG_VERSION_STRING, SYS_NAMELEN); + strncpy(name->version, CONFIG_VERSION_BUILD, SYS_NAMELEN); + strncpy(name->machine, CONFIG_ARCH, SYS_NAMELEN); return ret; }