]> git.ipfire.org Git - thirdparty/qemu.git/commit
qga: Fix undefined C behavior
authorEric Blake <eblake@redhat.com>
Fri, 20 Mar 2020 15:05:07 +0000 (10:05 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 4 Jun 2020 01:14:36 +0000 (20:14 -0500)
commite3531619f1431f029c2d09238f404bee0d3e9091
tree16ea5f32d89cae99c1064e400be39274db8601d5
parent4996bd71611c756681bf3dc410957946b5f7083f
qga: Fix undefined C behavior

The QAPI struct GuestFileWhence has a comment about how we are
exploiting equivalent values between two different integer types
shared in a union. But C says behavior is undefined on assignments to
overlapping storage when the two types are not the same width, and
indeed, 'int64_t value' and 'enum QGASeek name' are very likely to be
different in width.  Utilize a temporary variable to fix things.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: 0b4b49387
Fixes: Coverity CID 1421990
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
(cherry picked from commit a23f38a72921fa915536a981a4f8a9134512f120)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands.c