diff mbox series

[v2,1/2] isofs: fix timestamps beyond 2027

Message ID 20171019144811.2144678-1-arnd@arndb.de
State New
Headers show
Series [v2,1/2] isofs: fix timestamps beyond 2027 | expand

Commit Message

Arnd Bergmann Oct. 19, 2017, 2:47 p.m. UTC
isofs uses a 'char' variable to load the number of years since
1900 for an inode timestamp. On architectures that use a signed
char type by default, this results in an invalid date for
anything beyond 2027.

This changes the function argument to a 'u8' array, which
is defined the same way on all architectures, and unambiguously
lets us use years until 2155.

This should be backported to all kernels that might still be
in use by that date.

Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
v2: change function prototype instead of adding a cast
---
 fs/isofs/isofs.h | 2 +-
 fs/isofs/rock.h  | 2 +-
 fs/isofs/util.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.9.0

Comments

Jan Kara Oct. 19, 2017, 3:17 p.m. UTC | #1
On Thu 19-10-17 16:47:48, Arnd Bergmann wrote:
> isofs uses a 'char' variable to load the number of years since

> 1900 for an inode timestamp. On architectures that use a signed

> char type by default, this results in an invalid date for

> anything beyond 2027.

> 

> This changes the function argument to a 'u8' array, which

> is defined the same way on all architectures, and unambiguously

> lets us use years until 2155.

> 

> This should be backported to all kernels that might still be

> in use by that date.

> 

> Cc: stable@vger.kernel.org

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

...
> -int iso_date(char * p, int flag)

> +int iso_date(u8 *p, int flag)

>  {

>  	int year, month, day, hour, minute, second, tz;

>  	int crtime;

>  

> -	year = p[0];

> +	year = (int)(u8)p[0];


The cast seems unnecessary now?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
Arnd Bergmann Oct. 19, 2017, 3:29 p.m. UTC | #2
On Thu, Oct 19, 2017 at 5:17 PM, Jan Kara <jack@suse.cz> wrote:
> On Thu 19-10-17 16:47:48, Arnd Bergmann wrote:

>> isofs uses a 'char' variable to load the number of years since

>> 1900 for an inode timestamp. On architectures that use a signed

>> char type by default, this results in an invalid date for

>> anything beyond 2027.

>>

>> This changes the function argument to a 'u8' array, which

>> is defined the same way on all architectures, and unambiguously

>> lets us use years until 2155.

>>

>> This should be backported to all kernels that might still be

>> in use by that date.

>>

>> Cc: stable@vger.kernel.org

>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ...

>> -int iso_date(char * p, int flag)

>> +int iso_date(u8 *p, int flag)

>>  {

>>       int year, month, day, hour, minute, second, tz;

>>       int crtime;

>>

>> -     year = p[0];

>> +     year = (int)(u8)p[0];

>

> The cast seems unnecessary now?

>


Sorry, I must have rebased the patch incorrectly, this was intended to
be removed
of course.

      Arnd
Arnd Bergmann Oct. 31, 2017, 9:36 p.m. UTC | #3
On Tue, Oct 31, 2017 at 5:59 PM, Jan Kara <jack@suse.cz> wrote:
> On Thu 19-10-17 17:29:12, Arnd Bergmann wrote:

>> On Thu, Oct 19, 2017 at 5:17 PM, Jan Kara <jack@suse.cz> wrote:


>> >>

>> >> -     year = p[0];

>> >> +     year = (int)(u8)p[0];

>> >

>> > The cast seems unnecessary now?

>> >

>>

>> Sorry, I must have rebased the patch incorrectly, this was intended to

>> be removed

>> of course.

>

> OK, I've picked up this patch to my tree with this correction.


Thanks! I was planning to send the fixed version but didn't get
around to it before ELC, and by now I had forgotten about it.

       Arnd
diff mbox series

Patch

diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 133a456b0425..bd4047585431 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -106,7 +106,7 @@  static inline unsigned int isonum_733(char *p)
 	/* Ignore bigendian datum due to broken mastering programs */
 	return get_unaligned_le32(p);
 }
-extern int iso_date(char *, int);
+extern int iso_date(u8 *, int);
 
 struct inode;		/* To make gcc happy */
 
diff --git a/fs/isofs/rock.h b/fs/isofs/rock.h
index ed09e2b08637..f835976ce033 100644
--- a/fs/isofs/rock.h
+++ b/fs/isofs/rock.h
@@ -65,7 +65,7 @@  struct RR_PL_s {
 };
 
 struct stamp {
-	char time[7];
+	__u8 time[7];		/* actually 6 unsigned, 1 signed */
 } __attribute__ ((packed));
 
 struct RR_TF_s {
diff --git a/fs/isofs/util.c b/fs/isofs/util.c
index 005a15cfd30a..335f62db0b53 100644
--- a/fs/isofs/util.c
+++ b/fs/isofs/util.c
@@ -15,12 +15,12 @@ 
  * to GMT.  Thus  we should always be correct.
  */
 
-int iso_date(char * p, int flag)
+int iso_date(u8 *p, int flag)
 {
 	int year, month, day, hour, minute, second, tz;
 	int crtime;
 
-	year = p[0];
+	year = (int)(u8)p[0];
 	month = p[1];
 	day = p[2];
 	hour = p[3];