mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-26 02:25:00 -05:00
nfsd: minor off by one checks in __write_versions()
My static checker complains that if "len == remaining" then it means we have truncated the last character off the version string. The intent of the code is that we print as many versions as we can without truncating a version. Then we put a newline at the end. If the newline can't fit we return -EINVAL. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Jeff Layton <jlayton@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
067f96ef17
commit
818f2f57f2
1 changed files with 3 additions and 3 deletions
|
@ -606,7 +606,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
|
|||
num);
|
||||
sep = " ";
|
||||
|
||||
if (len > remaining)
|
||||
if (len >= remaining)
|
||||
break;
|
||||
remaining -= len;
|
||||
buf += len;
|
||||
|
@ -621,7 +621,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
|
|||
'+' : '-',
|
||||
minor);
|
||||
|
||||
if (len > remaining)
|
||||
if (len >= remaining)
|
||||
break;
|
||||
remaining -= len;
|
||||
buf += len;
|
||||
|
@ -629,7 +629,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
|
|||
}
|
||||
|
||||
len = snprintf(buf, remaining, "\n");
|
||||
if (len > remaining)
|
||||
if (len >= remaining)
|
||||
return -EINVAL;
|
||||
return tlen + len;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue