[PATCH] virsh: Fix overflow error of freepages command

Adam Julis posted 1 patch 1 month, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/6859348c7528492037524b94004e0c313c8ca3f9.1709627305.git.ajulis@redhat.com
There is a newer version of this series
tools/virsh-host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] virsh: Fix overflow error of freepages command
Posted by Adam Julis 1 month, 3 weeks ago
Trying to print pages of a size larger than the UINT_MAX of the given platform, a system error was printed, but this is a legitimate request, fixed

Signed-off-by: Adam Julis <ajulis@redhat.com>
---
 tools/virsh-host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 6c14be865f..dc1282e718 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -335,7 +335,7 @@ 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);
 
-- 
2.43.2
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] virsh: Fix overflow error of freepages command
Posted by Michal Prívozník 1 month, 3 weeks ago
On 3/5/24 09:29, Adam Julis wrote:
> Trying to print pages of a size larger than the UINT_MAX of the given platform, a system error was printed, but this is a legitimate request, fixed


I'd like to see explained here why UINT_MAX is not good enough and why
we can't use larger type (unsigned long long).

Also, please put 'Resolves: $URL' line here as this fixes an issue
reported in jira.

> 
> Signed-off-by: Adam Julis <ajulis@redhat.com>
> ---
>  tools/virsh-host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/virsh-host.c b/tools/virsh-host.c
> index 6c14be865f..dc1282e718 100644
> --- a/tools/virsh-host.c
> +++ b/tools/virsh-host.c
> @@ -335,7 +335,7 @@ 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)

Nit pick - we like to write this as UINT_MAX * 1024ULL.

>          goto cleanup;
>      kibibytes = VIR_DIV_UP(bytes, 1024);
>  

Michal
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org