summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-06-22 23:52:19 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-06-22 23:52:19 +0000
commit68fe655b77ab978f8d03f8feec46801220bd46c5 (patch)
treecf71e1513645d4dd977c3b1b4a92d6ec1578c8f6 /sys/compat/linux
parent5557b30319fbfe74844a640472fa29a826d1be8b (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')
-rw-r--r--sys/compat/linux/linux_getcwd.c5
-rw-r--r--sys/compat/linux/linux_misc.c40
2 files changed, 20 insertions, 25 deletions
diff --git a/sys/compat/linux/linux_getcwd.c b/sys/compat/linux/linux_getcwd.c
index 1f799433c4e..09ffc5404b7 100644
--- a/sys/compat/linux/linux_getcwd.c
+++ b/sys/compat/linux/linux_getcwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_getcwd.c,v 1.3 2002/03/14 01:26:50 millert Exp $ */
+/* $OpenBSD: linux_getcwd.c,v 1.4 2004/06/22 23:52:18 jfb Exp $ */
/* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */
/*-
@@ -59,6 +59,7 @@ int proc_isunder(struct proc *, struct proc*); /* missing from proc.h */
#include <compat/linux/linux_signal.h>
#include <compat/linux/linux_syscallargs.h>
#include <compat/linux/linux_util.h>
+#include <compat/linux/linux_dirent.h>
#include <machine/linux_machdep.h>
@@ -75,7 +76,7 @@ linux_getcwd_common(struct vnode *, struct vnode *,
static int
linux_vn_isunder(struct vnode *, struct vnode *, struct proc *);
-#define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4)
+#define DIRENT_MINSIZE (sizeof(struct dirent) - (LINUX_MAXNAMLEN+1) + 4)
/*
* Vnode variable naming conventions in this file:
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);