Skip to content

Commit 8d34fba

Browse files
committed
SR-5596: TimeZone.current returns wrong value
- The length passed to CFStringCreateWithBytes() included an extra random byte after the NUL. This meant the string was sometimes interpreted as non-ASCII (if the byte was >= 0x80) and the timezone would come back as NULL thus defaulting to GMT.
1 parent c85cbce commit 8d34fba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CoreFoundation/NumberDate.subproj/CFTimeZone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static CFTimeZoneRef __CFTimeZoneCreateSystem(void) {
793793
size_t zoneInfoDirLen = CFStringGetLength(__tzZoneInfo);
794794
if (strncmp(linkbuf, tzZoneInfo, zoneInfoDirLen) == 0) {
795795
name = CFStringCreateWithBytes(kCFAllocatorSystemDefault, (uint8_t *)linkbuf + zoneInfoDirLen,
796-
strlen(linkbuf) - zoneInfoDirLen + 2, kCFStringEncodingUTF8, false);
796+
strlen(linkbuf) - zoneInfoDirLen + 1, kCFStringEncodingUTF8, false);
797797
} else {
798798
name = CFStringCreateWithBytes(kCFAllocatorSystemDefault, (uint8_t *)linkbuf, strlen(linkbuf), kCFStringEncodingUTF8, false);
799799
}

0 commit comments

Comments
 (0)