mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virconf: Properly fix numeric overflow when parsing numbers in conf files
The previous fix didn't check the overflow in addition. Use the new
macro to check both multiplication and addition overflows.
Fixes: 8666523b7d
Closes: https://gitlab.com/libvirt/libvirt/-/issues/671
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
23cb613606
commit
a9ede822da
@ -347,13 +347,15 @@ virConfParseLong(virConfParserCtxt *ctxt, long long *val)
|
||||
return -1;
|
||||
}
|
||||
while ((ctxt->cur < ctxt->end) && (g_ascii_isdigit(CUR))) {
|
||||
if (l > LLONG_MAX / 10) {
|
||||
long long c = (CUR - '0');
|
||||
|
||||
if (VIR_MULTIPLY_ADD_IS_OVERFLOW(LLONG_MAX, l, 10, c)) {
|
||||
virConfError(ctxt, VIR_ERR_OVERFLOW,
|
||||
_("numeric overflow in conf value"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
l = l * 10 + (CUR - '0');
|
||||
l = l * 10 + c;
|
||||
NEXT;
|
||||
}
|
||||
if (neg)
|
||||
|
Loading…
Reference in New Issue
Block a user