mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: Fix overflow error of freepages command
Trying to print pages of a size larger than the UINT_MAX of the given platform (for example, 4G on 64-bit ARM), results in a system error even though this is a legitimate request. The vshCommandOptScaledInt() used for parsing the pagesize is given UINT_MAX as the upper limit. The parsed value is then divided by 1024 and fed to virNodeGetFreePages() which expects an unsigned int. We can't change the public API but the upper limit can be raised by the factor of 1024. Resolves: https://issues.redhat.com/browse/RHEL-23608 Signed-off-by: Adam Julis <ajulis@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ba3a5604c9
commit
bdee774285
@ -335,8 +335,10 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);
|
||||
|
||||
if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes, 1024, UINT_MAX) < 0)
|
||||
if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes,
|
||||
1024, UINT_MAX * 1024ULL) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
kibibytes = VIR_DIV_UP(bytes, 1024);
|
||||
|
||||
if (all) {
|
||||
|
Loading…
Reference in New Issue
Block a user