mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] isofs: fix undefined behavior in iso_date()
@ 2023-07-09  6:42 Linke Li
  2023-07-09 11:41 ` Matthew Wilcox
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Linke Li @ 2023-07-09  6:42 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Jan Kara, Linke Li

From: Linke Li <lilinke99@gmail.com>

Fix undefined behavior in the code by properly handling the left shift operaion.
Instead of left-shifting a negative value, explicitly cast -1 to an unsigned int
before the shift. This ensures well defined behavior and resolves any potential
issues.

Signed-off-by: Linke Li <lilinke99@gmail.com>
---
 fs/isofs/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/isofs/util.c b/fs/isofs/util.c
index e88dba721661..4c902901401a 100644
--- a/fs/isofs/util.c
+++ b/fs/isofs/util.c
@@ -37,7 +37,7 @@ int iso_date(u8 *p, int flag)
 
 		/* sign extend */
 		if (tz & 0x80)
-			tz |= (-1 << 8);
+			tz |= ((unsigned int)-1 << 8);
 		
 		/* 
 		 * The timezone offset is unreliable on some disks,
-- 
2.25.1


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

end of thread, other threads:[~2023-07-13 14:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-09  6:42 [PATCH] isofs: fix undefined behavior in iso_date() Linke Li
2023-07-09 11:41 ` Matthew Wilcox
2023-07-13  7:22   ` linke li
     [not found] ` <63c6f039-4b33-cdfc-1e49-fc9fc35d513e@web.de>
2023-07-10  6:10   ` linke li
2023-07-10  9:56 ` Dan Carpenter
2023-07-13 14:11   ` David Laight
2023-07-13 14:26     ` Dan Carpenter

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

all inboxes | Powered by JetHome®