提交 776f5279 编写于 作者: C Chris Lalancette

Remove use of strncpy in qemudExtractMonitorPath.

qemudExtractMonitorPath() was doing a VIR_ALLOC_N followed by a
strncpy.  However, this isn't necessary; we can do the same thing
using strndup, which is much safer.
Signed-off-by: NChris Lalancette <clalance@redhat.com>
上级 bf878aa9
...@@ -1029,12 +1029,12 @@ qemudExtractMonitorPath(virConnectPtr conn, ...@@ -1029,12 +1029,12 @@ qemudExtractMonitorPath(virConnectPtr conn,
*/ */
while (*tmp) { while (*tmp) {
if (c_isspace(*tmp)) { if (c_isspace(*tmp)) {
if (VIR_ALLOC_N(*path, (tmp-dev)+1) < 0) { *path = strndup(dev, tmp-dev);
if (*path == NULL) {
virReportOOMError(conn); virReportOOMError(conn);
return -1; return -1;
} }
strncpy(*path, dev, (tmp-dev));
(*path)[(tmp-dev)] = '\0';
/* ... now further update offset till we get EOL */ /* ... now further update offset till we get EOL */
*offset = tmp - haystack; *offset = tmp - haystack;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册