From: dv Date: Wed, 10 Apr 2024 13:03:41 +0000 (+0000) Subject: vmctl: fix incorrect scaling when converting disk images. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=82bc4c61b60e57630e8329510cab9976ff9fb1b5;p=openbsd vmctl: fix incorrect scaling when converting disk images. ctl_convert still had old logic assuming disk sizes were in MiB and not bytes, causing an attempt to create a new disk using the '-i' argument to generate impossibly large output disk images (e.g. 1 MiB ends up 1 TiB). Reported by and diff from Jesper Wallin. --- diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c index b4c10561d90..6621169dc5e 100644 --- a/usr.sbin/vmctl/main.c +++ b/usr.sbin/vmctl/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.75 2023/04/28 19:46:41 dv Exp $ */ +/* $OpenBSD: main.c,v 1.76 2024/04/10 13:03:41 dv Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -648,8 +648,6 @@ ctl_convert(const char *srcfile, const char *dstfile, int dsttype, size_t dstsiz if (dstsize == 0) dstsize = src.size; - else - dstsize *= 1048576; if (dstsize < (size_t)src.size) { errstr = "size cannot be smaller than input disk size"; goto done;