diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-06-22 23:52:19 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-06-22 23:52:19 +0000 |
commit | 68fe655b77ab978f8d03f8feec46801220bd46c5 (patch) | |
tree | cf71e1513645d4dd977c3b1b4a92d6ec1578c8f6 /sys/compat/linux/linux_misc.c | |
parent | 5557b30319fbfe74844a640472fa29a826d1be8b (diff) |
Replace a whole bunch of scary uses of strncpy() with strlcpy() and
use compat-specific MAXNAMLEN values where appropriate
ok millert@, pedro@
Diffstat (limited to 'sys/compat/linux/linux_misc.c')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 0c31e2d1d28..22062458206 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_misc.c,v 1.55 2003/12/02 03:46:45 nordin Exp $ */ +/* $OpenBSD: linux_misc.c,v 1.56 2004/06/22 23:52:18 jfb Exp $ */ /* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */ /*- @@ -520,18 +520,12 @@ linux_sys_uname(p, v, retval) int len; char *cp; - strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname) - 1); - luts.l_sysname[sizeof(luts.l_sysname) - 1] = '\0'; - strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename) - 1); - luts.l_nodename[sizeof(luts.l_nodename) - 1] = '\0'; - strncpy(luts.l_release, osrelease, sizeof(luts.l_release) - 1); - luts.l_release[sizeof(luts.l_release) - 1] = '\0'; - strncpy(luts.l_version, version, sizeof(luts.l_version) - 1); - luts.l_version[sizeof(luts.l_version) - 1] = '\0'; - strncpy(luts.l_machine, machine, sizeof(luts.l_machine) - 1); - luts.l_machine[sizeof(luts.l_machine) - 1] = '\0'; - strncpy(luts.l_domainname, domainname, sizeof(luts.l_domainname) - 1); - luts.l_domainname[sizeof(luts.l_domainname) - 1] = '\0'; + strlcpy(luts.l_sysname, ostype, sizeof(luts.l_sysname)); + strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); + strlcpy(luts.l_release, osrelease, sizeof(luts.l_release)); + strlcpy(luts.l_version, version, sizeof(luts.l_version)); + strlcpy(luts.l_machine, machine, sizeof(luts.l_machine)); + strlcpy(luts.l_domainname, domainname, sizeof(luts.l_domainname)); /* This part taken from the the uname() in libc */ len = sizeof(luts.l_version); @@ -556,11 +550,11 @@ linux_sys_olduname(p, v, retval) int len; char *cp; - strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname)); - strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); - strncpy(luts.l_release, osrelease, sizeof(luts.l_release)); - strncpy(luts.l_version, version, sizeof(luts.l_version)); - strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); + strlcpy(luts.l_sysname, ostype, sizeof(luts.l_sysname)); + strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); + strlcpy(luts.l_release, osrelease, sizeof(luts.l_release)); + strlcpy(luts.l_version, version, sizeof(luts.l_version)); + strlcpy(luts.l_machine, machine, sizeof(luts.l_machine)); /* This part taken from the the uname() in libc */ len = sizeof(luts.l_version); @@ -585,11 +579,11 @@ linux_sys_oldolduname(p, v, retval) int len; char *cp; - strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname)); - strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); - strncpy(luts.l_release, osrelease, sizeof(luts.l_release)); - strncpy(luts.l_version, version, sizeof(luts.l_version)); - strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); + strlcpy(luts.l_sysname, ostype, sizeof(luts.l_sysname)); + strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); + strlcpy(luts.l_release, osrelease, sizeof(luts.l_release)); + strlcpy(luts.l_version, version, sizeof(luts.l_version)); + strlcpy(luts.l_machine, machine, sizeof(luts.l_machine)); /* This part taken from the the uname() in libc */ len = sizeof(luts.l_version); |