svn commit: r190145 - head/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Fri Mar 20 04:08:58 PDT 2009
Author: kib
Date: Fri Mar 20 11:08:57 2009
New Revision: 190145
URL: http://svn.freebsd.org/changeset/base/190145
Log:
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
Modified:
head/sys/kern/vfs_cache.c
Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c Fri Mar 20 11:03:55 2009 (r190144)
+++ head/sys/kern/vfs_cache.c Fri Mar 20 11:08:57 2009 (r190145)
@@ -970,13 +970,13 @@ vn_fullpath1(struct thread *td, struct v
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 v
if (error)
break;
}
- *--bp = '/';
- buflen--;
- if (buflen < 0) {
+ if (buflen <= 0) {
numfullpathfail4++;
CACHE_RUNLOCK();
error = ENOMEM;
break;
}
+ *--bp = '/';
+ buflen--;
slash_prefixed = 1;
}
if (error)
More information about the svn-src-all
mailing list