git: cd6e526e268e - main - loader/libofw: Fix disk size truncation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 21 Feb 2024 03:19:14 UTC
The branch main has been updated by jhibbits:
URL: https://cgit.FreeBSD.org/src/commit/?id=cd6e526e268e4fdf1c9a65b9d792e67343f52307
commit cd6e526e268e4fdf1c9a65b9d792e67343f52307
Author: Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2024-02-20 22:08:54 +0000
Commit: Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2024-02-21 03:17:26 +0000
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.
---
stand/libofw/ofw_disk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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);