diff options
| author | Justin Hibbits <jhibbits@FreeBSD.org> | 2024-02-20 22:08:54 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2024-04-16 19:54:25 +0000 |
| commit | d6a4e4842943fb525061cfee34bc37a098cb7433 (patch) | |
| tree | 868ced91c13664ddbe7646d823e7892a33116e8f | |
| parent | 57ca2848c0aad6dbef66dbac5c0b0f0a6eb798c1 (diff) | |
loader/libofw: Fix disk size truncation
At present OF_ioctl first multiplies, then casts to 64-bit, meaning at
the asm level it truncates the result to 32-bit, then zero-extends it to
64-bit to return. Cast `n` to 64-bit before multiplying, so that the
correct result is returned.
(cherry picked from commit cd6e526e268e4fdf1c9a65b9d792e67343f52307)
| -rw-r--r-- | stand/libofw/ofw_disk.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c index e9002ca23fe9..d30454b70b74 100644 --- a/stand/libofw/ofw_disk.c +++ b/stand/libofw/ofw_disk.c @@ -174,7 +174,7 @@ ofwd_ioctl(struct open_file *f, u_long cmd, void *data) case DIOCGMEDIASIZE: block_size = OF_block_size(dev->d_handle); n = OF_blocks(dev->d_handle); - *(uint64_t *)data = (uint64_t)(n * block_size); + *(uint64_t *)data = ((uint64_t)n * block_size); break; default: return (ENOTTY); |
