summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2007-08-07 07:42:00 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2007-08-07 07:42:00 +0000
commit2151824e715d92a1e7c49e063e3628900dbc34f2 (patch)
tree11b954df441296987ed790c8f23d3563ea4b1039
parent48d86784de90c1b3c2b1ee7fca5b24c0ed5d14cc (diff)
fix the "double-path" errors seen with getcwd by saving the orignal
buffer position in vfs_getcwd_getcache() and restoring it on error. Use u_int32_t for the componentname hash, use the same type in the diagnostic code in relookup() to prevent unsigned vs signed errors. help, testing & ok kurt@ ok millert@, art@
-rw-r--r--sys/kern/vfs_getcwd.c8
-rw-r--r--sys/kern/vfs_lookup.c4
-rw-r--r--sys/sys/namei.h4
3 files changed, 10 insertions, 6 deletions
diff --git a/sys/kern/vfs_getcwd.c b/sys/kern/vfs_getcwd.c
index 99c52dfe584..fb24f5e48d2 100644
--- a/sys/kern/vfs_getcwd.c
+++ b/sys/kern/vfs_getcwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_getcwd.c,v 1.11 2007/05/30 04:27:42 beck Exp $ */
+/* $OpenBSD: vfs_getcwd.c,v 1.12 2007/08/07 07:41:59 thib Exp $ */
/* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */
/*
@@ -213,9 +213,11 @@ vfs_getcwd_getcache(struct vnode **lvpp, struct vnode **uvpp, char **bpp,
{
struct vnode *lvp, *uvp = NULL;
struct proc *p = curproc;
+ char *obp;
int error, vpid;
lvp = *lvpp;
+ obp = *bpp; /* Save orginal position to restore to on error */
error = cache_revlookup(lvp, uvpp, bpp, bufp);
if (error) {
@@ -254,8 +256,10 @@ vfs_getcwd_getcache(struct vnode **lvpp, struct vnode **uvpp, char **bpp,
*uvpp = NULL;
error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
- if (!error)
+ if (!error) {
+ *bpp = obp; /* restore the buffer */
return (-1);
+ }
}
vrele(lvp);
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 090e92ad34e..8a7b3ff3ea0 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_lookup.c,v 1.35 2006/06/25 15:01:53 sturm Exp $ */
+/* $OpenBSD: vfs_lookup.c,v 1.36 2007/08/07 07:41:59 thib Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */
/*
@@ -613,7 +613,7 @@ relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
int rdonly; /* lookup read-only flag bit */
int error = 0;
#ifdef NAMEI_DIAGNOSTIC
- int newhash; /* DEBUG: check name hash */
+ u_int32_t newhash; /* DEBUG: check name hash */
char *cp; /* DEBUG: check name ptr/len */
#endif
diff --git a/sys/sys/namei.h b/sys/sys/namei.h
index 043d7b42781..39dcf82ce06 100644
--- a/sys/sys/namei.h
+++ b/sys/sys/namei.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: namei.h,v 1.19 2007/06/02 01:34:50 thib Exp $ */
+/* $OpenBSD: namei.h,v 1.20 2007/08/07 07:41:59 thib Exp $ */
/* $NetBSD: namei.h,v 1.11 1996/02/09 18:25:20 christos Exp $ */
/*
@@ -85,7 +85,7 @@ struct nameidata {
char *cn_pnbuf; /* pathname buffer */
char *cn_nameptr; /* pointer to looked up name */
long cn_namelen; /* length of looked up component */
- u_long cn_hash; /* hash value of looked up name */
+ u_int32_t cn_hash; /* hash value of looked up name */
long cn_consume; /* chars to consume in lookup() */
} ni_cnd;
};