lkml.org 
[lkml]   [2023]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] isofs: fix undefined behavior in iso_date()
It looks like maybe there is an issue with "year" as well.

fs/isofs/util.c
19 int iso_date(u8 *p, int flag)
20 {
21 int year, month, day, hour, minute, second, tz;
22 int crtime;
23
24 year = p[0];
^^^^^
year is 0-255.

25 month = p[1];
26 day = p[2];
27 hour = p[3];
28 minute = p[4];
29 second = p[5];
30 if (flag == 0) tz = p[6]; /* High sierra has no time zone */
31 else tz = 0;
32
33 if (year < 0) {
^^^^^^^^
But this checks year for < 0 which is impossible. Should it be:

year = (signed char)p[0];?

34 crtime = 0;
35 } else {
36 crtime = mktime64(year+1900, month, day, hour, minute, second);
37
38 /* sign extend */
39 if (tz & 0x80)
40 tz |= (-1 << 8);
41
42 /*

regards,
dan carpenter

\
 
 \ /
  Last update: 2023-07-10 11:59    [W:0.069 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site