mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH 1/2] sandbox: fix signed integer overflow
Date: Mon,  3 Feb 2020 09:27:58 +0100	[thread overview]
Message-ID: <20200203082759.7014-1-ahmad@a3f.at> (raw)

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

             reply	other threads:[~2020-02-03  8:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-03  8:27 Ahmad Fatoum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200203082759.7014-1-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox