Replace WriteFileEx with WriteFile in qemu_create_pidfile

The function that writes pidfile for win32 uses WriteFileEx which is an
asynchronous IO function. The arguments given to WriteFileEx are allocated on
the stack and one of them is "in out". When the IO operation is actually
executed the calling function has already returned, so the arguments are no
longer allocated or allocated to another frame.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Fabien Chouteau 2011-11-07 15:36:14 +01:00 committed by Anthony Liguori
parent cca5de7389
commit bfc763fcfa

View File

@ -136,8 +136,9 @@ int qemu_create_pidfile(const char *filename)
return -1;
}
len = snprintf(buffer, sizeof(buffer), "%d\n", getpid());
ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
&overlap, NULL);
ret = WriteFile(file, (LPCVOID)buffer, (DWORD)len,
NULL, &overlap);
CloseHandle(file);
if (ret == 0) {
return -1;
}