mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] sandbox: fix signed integer overflow
@ 2020-02-03  8:27 Ahmad Fatoum
  2020-02-03  8:27 ` [PATCH 2/2] sandbox: hostfile: fix UB-inducing shift Ahmad Fatoum
  2020-02-10  8:09 ` [PATCH 1/2] sandbox: fix signed integer overflow Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2020-02-03  8:27 UTC (permalink / raw)
  To: barebox

On a 32-bit host system, UBSan reports:

===============================================================
UBSAN: Undefined behaviour in ./arch/sandbox/os/common.c:115:32
signed integer overflow:
83598 * 1000000000 cannot be represented in type 'long int'
===============================================================

Fix this.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 3ad12b4a30cd..3f9cc70770f6 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -112,7 +112,7 @@ uint64_t linux_get_time(void)
 
 	clock_gettime(CLOCK_MONOTONIC, &ts);
 
-	now = ts.tv_sec * 1000 * 1000 * 1000 + ts.tv_nsec;
+	now = ts.tv_sec * 1000ULL * 1000 * 1000 + ts.tv_nsec;
 
 	return now;
 }
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-10  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03  8:27 [PATCH 1/2] sandbox: fix signed integer overflow Ahmad Fatoum
2020-02-03  8:27 ` [PATCH 2/2] sandbox: hostfile: fix UB-inducing shift Ahmad Fatoum
2020-02-10  8:09 ` [PATCH 1/2] sandbox: fix signed integer overflow Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox