提交 d62f4c36 编写于 作者: C Chris Lalancette

Don't use virFileReadLimFD in qemuDomainRestore.

virFileReadLimFD is a poor fit for reading the header
of the restore file.  The problem is that virFileReadLimFD
returns an error when there is more data after the amount
you ask to read, but that is *expected* in this case.

This patch is essentially a revert of
1a4d5c95, but I don't think
that commit does what it says anyway.  It purports to prevent
an unwarranted OOM error, but since virFileReadLimFD will
allocate memory up to the maximum anyway, the upper limit
on the total amount of memory allocated is the same for either
the old version or the new version.  Since the old saferead
actually works and virFileReadLimFD does not, revert to
using saferead.
Signed-off-by: NChris Lalancette <clalance@redhat.com>
上级 320ea3a4
......@@ -5547,7 +5547,12 @@ static int qemudDomainRestore(virConnectPtr conn,
goto cleanup;
}
if (virFileReadLimFD(fd, header.xml_len, &xml) != header.xml_len) {
if (VIR_ALLOC_N(xml, header.xml_len) < 0) {
virReportOOMError();
goto cleanup;
}
if (saferead(fd, xml, header.xml_len) != header.xml_len) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("failed to read XML"));
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册