[libvirt] [PATCH] Ensure remote daemon unions are always non-zero length

If the remote daemon args/ret unions ever become zero length (due to a build / Makefile bug) then bad stuff happens at runtime. Add a compile time assertion to check for this kind of problem * daemon/remote.h: Ensure non-zero length unions --- daemon/remote.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/daemon/remote.h b/daemon/remote.h index fd8d381..1eb8386 100644 --- a/daemon/remote.h +++ b/daemon/remote.h @@ -30,18 +30,22 @@ typedef union { # include "remote_dispatch_args.h" } dispatch_args; +verify(sizeof(dispatch_args) > 0); typedef union { # include "remote_dispatch_ret.h" } dispatch_ret; +verify(sizeof(dispatch_ret) > 0); typedef union { # include "qemu_dispatch_args.h" } qemu_dispatch_args; +verify(sizeof(qemu_dispatch_args) > 0); typedef union { # include "qemu_dispatch_ret.h" } qemu_dispatch_ret; +verify(sizeof(qemu_dispatch_ret) > 0); -- 1.7.2.1

On 08/24/2010 07:21 AM, Daniel P. Berrange wrote:
If the remote daemon args/ret unions ever become zero length (due to a build / Makefile bug) then bad stuff happens at runtime. Add a compile time assertion to check for this kind of problem
* daemon/remote.h: Ensure non-zero length unions --- daemon/remote.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
ACK. It doesn't solve the parallel makefile race, but at least prevents us from proceeding to a broken executable. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake