mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-24 06:53:11 +00:00
virconf: Fix numeric overflow when parsing numbers in conf files
The number is parsed manually without making sure it'll fit.
Fixes: 3bbac7cdb6
Closes: https://gitlab.com/libvirt/libvirt/-/issues/671
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5d77061d7e
commit
8666523b7d
@ -347,6 +347,12 @@ virConfParseLong(virConfParserCtxt *ctxt, long long *val)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while ((ctxt->cur < ctxt->end) && (g_ascii_isdigit(CUR))) {
|
while ((ctxt->cur < ctxt->end) && (g_ascii_isdigit(CUR))) {
|
||||||
|
if (l > LLONG_MAX / 10) {
|
||||||
|
virConfError(ctxt, VIR_ERR_OVERFLOW,
|
||||||
|
_("numeric overflow in conf value"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
l = l * 10 + (CUR - '0');
|
l = l * 10 + (CUR - '0');
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user