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:
Konstantin Belousov 2009-03-20 11:08:57 +00:00
parent 83817ce3b1
commit 15fb32c07d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190145

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)