From 4f0cb4136f9f45014befb5ce37d68cef20bcb683 Mon Sep 17 00:00:00 2001 From: Tom Giordano Date: Thu, 22 Dec 2011 00:44:14 +1100 Subject: timezone: data file should be 32 bit aligned The zoneinfo.dat file is memory mapped and then read as an int array. On some platforms this is causing alignment errors (SIGBUS) because the records are not 32 bit aligned. My changes: Fixes for 4.2 and also updates zoneinfo to the latest version Change-Id: Ieea8ef07e49ef86d139c52ebfccf4159c0ebd887 --- libc/tools/zoneinfo/ZoneCompactor.java | 7 +++++++ libc/tools/zoneinfo/generate | 5 +++-- libc/zoneinfo/zoneinfo.dat | Bin 499422 -> 500840 bytes libc/zoneinfo/zoneinfo.idx | Bin 29848 -> 29848 bytes libc/zoneinfo/zoneinfo.version | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libc/tools/zoneinfo/ZoneCompactor.java b/libc/tools/zoneinfo/ZoneCompactor.java index b657748..cc77c94 100644 --- a/libc/tools/zoneinfo/ZoneCompactor.java +++ b/libc/tools/zoneinfo/ZoneCompactor.java @@ -55,11 +55,13 @@ public class ZoneCompactor { InputStream in = new FileInputStream(inFile); byte[] buf = new byte[8192]; + int length = 0; while (true) { int nbytes = in.read(buf); if (nbytes == -1) { break; } + length += nbytes; out.write(buf, 0, nbytes); byte[] nret = new byte[ret.length + nbytes]; @@ -67,6 +69,8 @@ public class ZoneCompactor { System.arraycopy(buf, 0, nret, ret.length, nbytes); ret = nret; } + if (length%4 != 0) + out.write(new byte[] {00,00,00,00}, 0, 4 - length % 4); out.flush(); return ret; } @@ -105,6 +109,9 @@ public class ZoneCompactor { lengths.put(s, new Integer((int)length)); start += length; + if (start % 4 != 0) + start += 4 - start % 4; + byte[] data = copyFile(f, zoneInfo); TimeZone tz = ZoneInfo.make(s, data); diff --git a/libc/tools/zoneinfo/generate b/libc/tools/zoneinfo/generate index ab2617f..7017e90 100755 --- a/libc/tools/zoneinfo/generate +++ b/libc/tools/zoneinfo/generate @@ -92,7 +92,7 @@ def upgrade_to(ftp, filename): subprocess.check_call(['javac', '-d', '.', '%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir, '%s/ZoneInfo.java' % bionic_libc_tools_zoneinfo_dir]) - subprocess.check_call(['java', 'ZoneCompactor', 'setup', 'data']) + subprocess.check_call(['java', '-classpath', '.', 'ZoneCompactor', 'setup', 'data']) print 'Updating bionic from %s to %s...' % (current_tzdata_version(), version) # Move the .dat and .idx files... @@ -116,7 +116,8 @@ ftp.cwd('tz/releases') tzdata_filenames = [] for filename in ftp.nlst(): if filename.startswith('tzdata20'): - tzdata_filenames.append(filename) + if filename.endswith('tar.gz'): + tzdata_filenames.append(filename) tzdata_filenames.sort() # If you're several releases behind, we'll walk you through the upgrades one by one. diff --git a/libc/zoneinfo/zoneinfo.dat b/libc/zoneinfo/zoneinfo.dat index cb0507a..cd4b4cc 100644 Binary files a/libc/zoneinfo/zoneinfo.dat and b/libc/zoneinfo/zoneinfo.dat differ diff --git a/libc/zoneinfo/zoneinfo.idx b/libc/zoneinfo/zoneinfo.idx index c93b637..1f5f538 100644 Binary files a/libc/zoneinfo/zoneinfo.idx and b/libc/zoneinfo/zoneinfo.idx differ diff --git a/libc/zoneinfo/zoneinfo.version b/libc/zoneinfo/zoneinfo.version index 73bb417..0bbfa63 100644 --- a/libc/zoneinfo/zoneinfo.version +++ b/libc/zoneinfo/zoneinfo.version @@ -1 +1 @@ -2012h +2012j -- cgit v1.1