mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
internal: Refuse values exceeding range of 'unsigned int' in virCheckFlags
Historically our migration APIs declare 'unsigned long flags'. Since it's baked into our API we can't change that but we can avoid compatibility problems by preemptively refusing the extra range on certain arches to prevent future surprise. Modify the macro to verify that value passed inside 'flags' doesn't exceed the range of 'unsigned int'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
35e36f9e29
commit
bfc188e82c
@ -269,10 +269,17 @@
|
||||
*/
|
||||
#define virCheckFlags(supported, retval) \
|
||||
do { \
|
||||
unsigned long __unsuppflags = flags & ~(supported); \
|
||||
unsigned int __uiflags = flags; \
|
||||
unsigned int __unsuppflags = flags & ~(supported); \
|
||||
if (__uiflags != flags) { \
|
||||
virReportInvalidArg(flags, \
|
||||
_("unsupported use of long flags in function %s"), \
|
||||
__FUNCTION__); \
|
||||
return retval; \
|
||||
} \
|
||||
if (__unsuppflags) { \
|
||||
virReportInvalidArg(flags, \
|
||||
_("unsupported flags (0x%lx) in function %s"), \
|
||||
_("unsupported flags (0x%x) in function %s"), \
|
||||
__unsuppflags, __FUNCTION__); \
|
||||
return retval; \
|
||||
} \
|
||||
@ -291,10 +298,17 @@
|
||||
*/
|
||||
#define virCheckFlagsGoto(supported, label) \
|
||||
do { \
|
||||
unsigned long __unsuppflags = flags & ~(supported); \
|
||||
unsigned int __uiflags = flags; \
|
||||
unsigned int __unsuppflags = flags & ~(supported); \
|
||||
if (__uiflags != flags) { \
|
||||
virReportInvalidArg(flags, \
|
||||
_("unsupported use of long flags in function %s"), \
|
||||
__FUNCTION__); \
|
||||
goto label; \
|
||||
} \
|
||||
if (__unsuppflags) { \
|
||||
virReportInvalidArg(flags, \
|
||||
_("unsupported flags (0x%lx) in function %s"), \
|
||||
_("unsupported flags (0x%x) in function %s"), \
|
||||
__unsuppflags, __FUNCTION__); \
|
||||
goto label; \
|
||||
} \
|
||||
|
Loading…
x
Reference in New Issue
Block a user