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
This commit is contained in:
kib 2009-03-20 11:08:57 +00:00
parent 2e1bae397f
commit c8b4c76eed

View File

@ -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)