From: krw Date: Fri, 12 Aug 2022 00:32:59 +0000 (+0000) Subject: Coverity says multiplying two uint32_t's and assigning them to X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cb33a3f65fa74ec2591df1744951d81177ec9bd3;p=openbsd Coverity says multiplying two uint32_t's and assigning them to a uint64_t may not produce the (humanly) obvious result. Cast one of them to a (uint64_t) in the hope of invoking the appropriate int promotion god. CID 1519495 --- diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 90bdd46d7a7..7f65013eb8a 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.250 2022/08/11 20:22:27 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.251 2022/08/12 00:32:59 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -515,7 +515,8 @@ gpt_get_parts(struct buf *bp, void (*strat)(struct buf *), struct disklabel *lp, partnum = letoh32(gh->gh_part_num); partsize = letoh32(gh->gh_part_size); - sectors = (partnum * partsize + lp->d_secsize - 1) / lp->d_secsize; + sectors = ((uint64_t)partnum * partsize + lp->d_secsize - 1) / + lp->d_secsize; ngp = mallocarray(sectors, lp->d_secsize, M_DEVBUF, M_NOWAIT | M_ZERO); if (ngp == NULL) {