提交 5328780b 编写于 作者: M Michal Privoznik 提交者: Cole Robinson

virNetSocketNewConnectUNIX: Don't unlink(NULL)

There is a possibility that we jump onto error label with @lockpath
still initialized to NULL. Here, the @lockpath should be unlink()-ed,
but passing there a NULL is not a good idea. Don't do that. In fact,
we should call unlink() only if we created the lock file successfully.
Reported-by: NJohn Ferlan <jferlan@redhat.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 1fdac3d9)
上级 c6e7a9ea
......@@ -622,7 +622,7 @@ int virNetSocketNewConnectUNIX(const char *path,
usleep(5000);
}
if (lockfd) {
if (lockfd != -1) {
unlink(lockpath);
VIR_FORCE_CLOSE(lockfd);
VIR_FREE(lockpath);
......@@ -640,12 +640,13 @@ int virNetSocketNewConnectUNIX(const char *path,
return 0;
error:
if (lockfd)
if (lockfd != -1) {
unlink(lockpath);
VIR_FORCE_CLOSE(lockfd);
}
VIR_FREE(lockpath);
VIR_FREE(rundir);
VIR_FORCE_CLOSE(fd);
VIR_FORCE_CLOSE(lockfd);
return -1;
}
#else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册