dosfstools/0000-Fix-signed-integer-overflow-in-FSTART.patch
2020-07-01 15:15:47 +08:00

31 lines
951 B
Diff

From ed9facfbb0fa33e70ab95c21d49525f4f96224e2 Mon Sep 17 00:00:00 2001
From: Jakub Wilk <jwilk@jwilk.net>
Date: Tue, 11 Jul 2017 01:01:20 +0200
Subject: [PATCH 25/86] Fix signed integer overflow in FSTART
uint16_t was promoted to int, and then left shift could overflow it.
Add explicit cast to uint32_t to avoid undefined behavior.
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Andreas Bombe <aeb@debian.org>
---
src/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/check.c b/src/check.c
index 0db301d..a2a752f 100644
--- a/src/check.c
+++ b/src/check.c
@@ -47,7 +47,7 @@ static DOS_FILE *root;
/* get start field of a dir entry */
#define FSTART(p,fs) \
((uint32_t)le16toh(p->dir_ent.start) | \
- (fs->fat_bits == 32 ? le16toh(p->dir_ent.starthi) << 16 : 0))
+ (fs->fat_bits == 32 ? (uint32_t)le16toh(p->dir_ent.starthi) << 16 : 0))
#define MODIFY(p,i,v) \
do { \
--
1.8.3.1