summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_cache.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-03-20 11:08:57 +0000
committerkib <kib@FreeBSD.org>2009-03-20 11:08:57 +0000
commitc8b4c76eed87a28addbdc90f84635dd414796b51 (patch)
treeaf88da3eeda5a5b1231fb1564775d89d04fc8e4e /sys/kern/vfs_cache.c
parent2e1bae397f4c7c238089ede040eb5272403d8fc1 (diff)
downloadFreeBSD-src-c8b4c76eed87a28addbdc90f84635dd414796b51.zip
FreeBSD-src-c8b4c76eed87a28addbdc90f84635dd414796b51.tar.gz
Do not underflow the buffer and then report the problem. Check for the
condition before the buffer write. Also, since buflen is unsigned, previous check was ignored. Reviewed by: marcus Tested by: pho
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r--sys/kern/vfs_cache.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index f114c18..0d506bc 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -970,13 +970,13 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
if (error)
return (error);
}
- *--bp = '/';
- buflen--;
- if (buflen < 0) {
+ if (buflen <= 0) {
numfullpathfail4++;
CACHE_RUNLOCK();
return (ENOMEM);
}
+ *--bp = '/';
+ buflen--;
slash_prefixed = 1;
}
while (vp != rdir && vp != rootvnode) {
@@ -1013,14 +1013,14 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
if (error)
break;
}
- *--bp = '/';
- buflen--;
- if (buflen < 0) {
+ if (buflen <= 0) {
numfullpathfail4++;
CACHE_RUNLOCK();
error = ENOMEM;
break;
}
+ *--bp = '/';
+ buflen--;
slash_prefixed = 1;
}
if (error)
OpenPOWER on IntegriCloud