You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/09/05 06:55:30 UTC

[incubator-nuttx] branch master updated: nuttx/libs/libc/time: fix runtime error by UBSan

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 74ab851ac4 nuttx/libs/libc/time: fix runtime error by UBSan
74ab851ac4 is described below

commit 74ab851ac428d397155a9a869751ea5d1a512cb2
Author: Junbo Zheng <zh...@xiaomi.com>
AuthorDate: Mon Sep 5 10:15:09 2022 +0800

    nuttx/libs/libc/time: fix runtime error by UBSan
    
    Signed-off-by: Junbo Zheng <zh...@xiaomi.com>
---
 libs/libc/time/lib_localtime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c
index 5058a8d2e2..0f981b08d3 100644
--- a/libs/libc/time/lib_localtime.c
+++ b/libs/libc/time/lib_localtime.c
@@ -461,7 +461,7 @@ static int_fast64_t detzcode64(FAR const char *codep)
   result = (codep[0] & 0x80) ? -1 : 0;
   for (i = 0; i < 8; ++i)
     {
-      result = (result << 8) | (codep[i] & 0xff);
+      result = (result * 256) | (codep[i] & 0xff);
     }
 
   return result;