diff options
author | kib <kib@FreeBSD.org> | 2009-03-20 11:08:57 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2009-03-20 11:08:57 +0000 |
commit | c8b4c76eed87a28addbdc90f84635dd414796b51 (patch) | |
tree | af88da3eeda5a5b1231fb1564775d89d04fc8e4e /sys/kern | |
parent | 2e1bae397f4c7c238089ede040eb5272403d8fc1 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/kern/vfs_cache.c | 12 |
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) |