提交 b4f841d9 编写于 作者: D Daniel P. Berrange

Fix buffer termination off-by-1 in link comparison code

上级 6d3f1d51
Sat Dec 1 10:22:34 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_driver.c: Fix off-by-1 buffer NULL termination in
symlink comparison code
Fri Nov 30 17:50:34 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/xml.c, src/xml.h: Disable xen specific functions if
......
......@@ -2667,7 +2667,7 @@ checkLinkPointsTo(const char *checkLink,
char *p;
strncpy(dir, checkLink, PATH_MAX);
dir[PATH_MAX] = '\0';
dir[PATH_MAX-1] = '\0';
if (!(p = strrchr(dir, '/'))) {
qemudLog(QEMUD_WARN, "Symlink path '%s' is not absolute", checkLink);
......@@ -2685,7 +2685,7 @@ checkLinkPointsTo(const char *checkLink,
}
strncpy(dest, tmp, PATH_MAX);
dest[PATH_MAX] = '\0';
dest[PATH_MAX-1] = '\0';
}
/* canonicalize both paths */
......@@ -2693,14 +2693,14 @@ checkLinkPointsTo(const char *checkLink,
qemudLog(QEMUD_WARN, "Failed to expand path '%s' :%s",
dest, strerror(errno));
strncpy(real, dest, PATH_MAX);
real[PATH_MAX] = '\0';
real[PATH_MAX-1] = '\0';
}
if (!realpath(checkDest, checkReal)) {
qemudLog(QEMUD_WARN, "Failed to expand path '%s' :%s",
checkDest, strerror(errno));
strncpy(checkReal, checkDest, PATH_MAX);
checkReal[PATH_MAX] = '\0';
checkReal[PATH_MAX-1] = '\0';
}
/* compare */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册