linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udf: Incorrect handling of timezone
@ 2020-01-19 12:49 Pali Rohár
  2020-01-20 11:31 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Pali Rohár @ 2020-01-19 12:49 UTC (permalink / raw)
  To: linux-fsdevel, Jan Kara

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

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@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2020-01-20 23:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-19 12:49 udf: Incorrect handling of timezone Pali Rohár
2020-01-20 11:31 ` Jan Kara
2020-01-20 23:35   ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).