summaryrefslogtreecommitdiffstats
path: root/sys/security
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2006-06-01 15:38:30 +0000
committercsjp <csjp@FreeBSD.org>2006-06-01 15:38:30 +0000
commit65422bb62220eaa28b25a6a863563b85acd3df50 (patch)
treea07f1994cd610648d28b1fb93b906b0f19b3eae7 /sys/security
parente66637299eb2c5aff5fb88d222a97050207fe19f (diff)
downloadFreeBSD-src-65422bb62220eaa28b25a6a863563b85acd3df50.zip
FreeBSD-src-65422bb62220eaa28b25a6a863563b85acd3df50.tar.gz
Check to see if the rootdir is the same as the current working directory.
If it is, and the pathname was relative, do not separate the componenets with a '/' character. Obtained from: TrustedBSD Project
Diffstat (limited to 'sys/security')
-rw-r--r--sys/security/audit/audit_bsm_klib.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/security/audit/audit_bsm_klib.c b/sys/security/audit/audit_bsm_klib.c
index 5489a2e..87d715a 100644
--- a/sys/security/audit/audit_bsm_klib.c
+++ b/sys/security/audit/audit_bsm_klib.c
@@ -489,10 +489,11 @@ canon_path(struct thread *td, char *path, char *cpath)
char *retbuf, *freebuf;
struct vnode *vnp;
struct filedesc *fdp;
- int error, vfslocked;
+ int cisr, error, vfslocked;
fdp = td->td_proc->p_fd;
bufp = path;
+ cisr = 0;
FILEDESC_LOCK(fdp);
if (*(path) == '/') {
while (*(bufp) == '/')
@@ -511,6 +512,7 @@ canon_path(struct thread *td, char *path, char *cpath)
}
} else {
vnp = fdp->fd_cdir; /* Prepend the current dir. */
+ cisr = (fdp->fd_rdir == fdp->fd_cdir);
vref(vnp);
bufp = path;
}
@@ -527,8 +529,14 @@ canon_path(struct thread *td, char *path, char *cpath)
vn_lock(vnp, LK_EXCLUSIVE | LK_RETRY, td);
error = vn_fullpath(td, vnp, &retbuf, &freebuf);
if (error == 0) {
- /* Copy and free buffer allocated by vn_fullpath(). */
- snprintf(cpath, MAXPATHLEN, "%s/%s", retbuf, bufp);
+ /* Copy and free buffer allocated by vn_fullpath().
+ * If the current working directory was the same as
+ * the root directory, and the path was a relative
+ * pathname, do not separate the two components with
+ * the '/' character.
+ */
+ snprintf(cpath, MAXPATHLEN, "%s%s%s", retbuf,
+ cisr ? "" : "/", bufp);
free(freebuf, M_TEMP);
} else
cpath[0] = '\0';
OpenPOWER on IntegriCloud