udf: Incorrect handling of timezone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello! I looked at udf code which converts linux time to UDF time and I
found out that conversion of timezone is incorrect.

Relevant code from udf_time_to_disk_stamp() function:

	int16_t offset;

	offset = -sys_tz.tz_minuteswest;

	dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));

UDF 2.60 2.1.4.1 Uint16 TypeAndTimezone; says:

  For the following descriptions Type refers to the most significant 4 bits of this
  field, and TimeZone refers to the least significant 12 bits of this field, which is
  interpreted as a signed 12-bit number in two’s complement form.

  TimeZone ... If this field contains -2047 then the time zone has not been specified.

As offset is of signed 16bit integer, (offset & 0x0FFF) result always
clears sign bit and therefore timezone is stored to UDF fs incorrectly.

This needs to be fixed, sign bit from tz_minuteswest needs to be
propagated to 12th bit in typeAndTimezone member.

Also tz_minuteswest is of int type, so conversion to int16_t (or more
precisely int12_t) can be truncated. So this needs to be handled too.

-- 
Pali Rohár
pali.rohar@xxxxxxxxx

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux