From: Adam Julis Date: Tue, 5 Mar 2024 10:43:03 +0000 (+0100) Subject: virsh: Fix overflow error of freepages command X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bdee774285da1f0103ceeecb255a0113681d234c;p=libvirt.git 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 Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 6c14be865f..90ff46c5c4 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -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) {