提交 818f2f57 编写于 作者: D Dan Carpenter 提交者: J. Bruce Fields

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: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NJeff Layton <jlayton@primarydata.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 067f96ef
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册