qga: flush explicitly when needed
commit895b00f62a7e86724dc7352d67c7808d37366130
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 25 Nov 2015 12:59:11 +0000 (25 13:59 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 25 Nov 2015 23:56:31 +0000 (25 17:56 -0600)
tree4262acf90a4eb9aca73245062014b5869f5b109e
parentf2b608ab80a336b0136d35d9b49419a917656d44
qga: flush explicitly when needed

According to the specification:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html

"the application shall ensure that output is not directly followed by
input without an intervening call to fflush() or to a file positioning
function (fseek(), fsetpos(), or rewind()), and input is not directly
followed by output without an intervening call to a file positioning
function, unless the input operation encounters end-of-file."

Without this change, an fwrite() followed by an fread() may lose the
previously written content, as shown in the following test.

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1210246

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
* don't confuse {write,read}() with f{write,read}() in
  commit msg (Laszlo)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-posix.c