diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7184784f20..cf45a88518 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2169,7 +2169,8 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd) if (bandwidth) { /* bandwidth is ulong MiB/s, but the typed parameter is * ullong bytes/s; make sure we don't overflow */ - if (bandwidth + 0ULL > ULLONG_MAX >> 20) { + unsigned long long limit = MIN(ULONG_MAX, ULLONG_MAX >> 20); + if (bandwidth > limit) { virReportError(VIR_ERR_OVERFLOW, _("bandwidth must be less than %llu"), ULLONG_MAX >> 20);