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 2023/11/15 15:14:47 UTC

(nuttx) branch master updated: fs/fat: fix ubsan warning of shift-out-of-bounds

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/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 6104f32afc fs/fat: fix ubsan warning of shift-out-of-bounds
6104f32afc is described below

commit 6104f32afc4018632dd425ff1c8349e11a3c7bae
Author: chao an <an...@xiaomi.com>
AuthorDate: Wed Nov 15 20:55:29 2023 +0800

    fs/fat: fix ubsan warning of shift-out-of-bounds
    
    ubsan_prologue: ================================================================================
    ubsan_prologue: UBSAN: shift-out-of-bounds in fat/fs_fat32util.c:989:40
    __ubsan_handle_shift_out_of_bounds: left shift of 268435455 by 4 places cannot be represented in type 'int'
    ubsan_epilogue: ================================================================================
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 fs/fat/fs_fat32util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fat/fs_fat32util.c b/fs/fat/fs_fat32util.c
index 1831e9fc29..a4a01d2f79 100644
--- a/fs/fat/fs_fat32util.c
+++ b/fs/fat/fs_fat32util.c
@@ -986,7 +986,7 @@ int fat_putcluster(struct fat_mountpt_s *fs, uint32_t clusterno,
                   /* Save the LS four bits of the next cluster */
 
                   value = (fs->fs_buffer[fatindex] & 0x0f) |
-                           nextcluster << 4;
+                           (uint8_t)nextcluster << 4;
                 }
               else
                 {