We were incorrectly passing a pointer to a pointer of an
unsigned long long, when we just wanted to pass a pointer
to the unsigned long long.  This is especially bad on 32-bit
systems, where we're then writing a 64-bits into a 32-bit value
within ioctl.

We fix this to pass a pointer to the unsigned long long.

Test: On 32-bit device, no longer see native crash from toybox
Bug: http://b/151311535
Signed-off-by: Greg Kaiser <[email protected]>
---
 lib/portability.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
From a81dc0a3fc3e069228b77aee80062843d7ee09a2 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Thu, 12 Mar 2020 09:00:00 -0700
Subject: [PATCH] Fix get_block_device_size() for linux

We were incorrectly passing a pointer to a pointer of an
unsigned long long, when we just wanted to pass a pointer
to the unsigned long long.  This is especially bad on 32-bit
systems, where we're then writing a 64-bits into a 32-bit value
within ioctl.

We fix this to pass a pointer to the unsigned long long.

Test: On 32-bit device, no longer see native crash from toybox
Bug: http://b/151311535
Signed-off-by: Greg Kaiser <[email protected]>
---
 lib/portability.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portability.c b/lib/portability.c
index 145ac474..26b854d6 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -592,6 +592,6 @@ int get_block_device_size(int fd, unsigned long long* size)
 #elif defined(__linux__)
 int get_block_device_size(int fd, unsigned long long* size)
 {
-  return (ioctl(fd, BLKGETSIZE64, &size) >= 0);
+  return (ioctl(fd, BLKGETSIZE64, size) >= 0);
 }
 #endif
-- 
2.25.1.481.gfbce0eb801-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to