tz behavior difference TZif vs. TZif2

Robbin Kawabata robbin at sundew.sfbay.sun.com
Fri Mar 24 22:04:21 UTC 2006


The zic.c fix of 3/23/06 still has a problem.

The problem described in below email is against 2006b/src64/zic.c.
The problem still exists after the 3/23/06 zic.c fix is applied.

------------- Begin Forwarded Message -------------
Date: Thu, 23 Mar 2006 14:54:43 -0800
From: Kenjiro Tsuji <kenjiro.tsuji at sun.com>
Subject: zic.c

This seems like a bug of zic.c.
In writezone(), around line 1609, there is a chance that
it causes an illegal memory access, as the following:

		if (thistimecnt == 0)
			writetype[types[thistimelim - 1]] = TRUE;

If thistimelim is 0 here, types[thistimelim-1] will be an access
to types[-1].  On sparc with gcc, types[-1] is likely to return
1, as a result, the above will be writetype[1] = TRUE, which means
not LMT but CCT will be referred.
So, if you put dummy declarations around types[] declaration as the
following, you will always get the result that is equivalent to
others, even on SPARC with gcc:

	register FILE *			fp;
	register int			i, j;
	register int			leapcnt32, leapi32;
	register int			timecnt32, timei32;
	register int			pass;
	static char *			fullname;
	static const struct tzhead	tzh0;
	static struct tzhead		tzh;
	zic_t				ats[TZ_MAX_TIMES];
->	unsigned char			dummy1 = 0;
	unsigned char			types[TZ_MAX_TIMES];
->	unsigned char			dummy2 = 0;
------------- End Forwarded Message -------------

If zic (with fix of 3/23/06) is built with gcc on x86 (Solaris), the Cocos 
file is bad - "LMT" is written to the abbreviations field:

% od -xc zoneinfo_fix_gcc.i386/Indian/Cocos
0000000    545a    6966    3200    0000    0000    0000    0000    0000
           T   Z   i   f   2  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000020    0000    0000    0000    0001    0000    0001    0000    0000
          \0  \0  \0  \0  \0  \0  \0 001  \0  \0  \0 001  \0  \0  \0  \0
0000040    0000    0000    0000    0001    0000    0004    0000    5adc
          \0  \0  \0  \0  \0  \0  \0 001  \0  \0  \0 004  \0  \0   Z 334
0000060    0000    4c4d    5400    0000    545a    6966    3200    0000
          \0  \0   L   M   T  \0  \0  \0   T   Z   i   f   2  \0  \0  \0
0000100    0000    0000    0000    0000    0000    0000    0000    0002
          \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0 002
0000120    0000    0002    0000    0000    0000    0001    0000    0002
          \0  \0  \0 002  \0  \0  \0  \0  \0  \0  \0 001  \0  \0  \0 002
0000140    0000    0008    ffff    ffff    7c55    26a4    0100    005a
          \0  \0  \0  \b 377 377 377 377   |   U   & 244 001  \0  \0   Z
0000160    dc00    0000    005b    6800    044c    4d54    0043    4354
         334  \0  \0  \0  \0   [   h  \0 004   L   M   T  \0   C   C   T
0000200    0000    0000    000a    4343    542d    363a    3330    0a00
          \0  \0  \0  \0  \0  \n   C   C   T   -   6   :   3   0  \n
0000217

Note if zic is built with gcc on sparc, the Cocos file is "OK" - "CCT" is 
written to the abbreviations field:

% od -xc zoneinfo_fix_gcc.sparc/Indian/Cocos
0000000    545a    6966    3200    0000    0000    0000    0000    0000
           T   Z   i   f   2  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0000020    0000    0000    0000    0001    0000    0001    0000    0000
          \0  \0  \0  \0  \0  \0  \0 001  \0  \0  \0 001  \0  \0  \0  \0
0000040    0000    0000    0000    0001    0000    0004    0000    5b68
          \0  \0  \0  \0  \0  \0  \0 001  \0  \0  \0 004  \0  \0   [   h
0000060    0000    4343    5400    0000    545a    6966    3200    0000
          \0  \0   C   C   T  \0  \0  \0   T   Z   i   f   2  \0  \0  \0
0000100    0000    0000    0000    0000    0000    0000    0000    0002
          \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0 002
0000120    0000    0002    0000    0000    0000    0001    0000    0002
          \0  \0  \0 002  \0  \0  \0  \0  \0  \0  \0 001  \0  \0  \0 002
0000140    0000    0008    ffff    ffff    7c55    26a4    0100    005a
          \0  \0  \0  \b 377 377 377 377   |   U   & 244 001  \0  \0   Z
0000160    dc00    0000    005b    6800    044c    4d54    0043    4354
         334  \0  \0  \0  \0   [   h  \0 004   L   M   T  \0   C   C   T
0000200    0000    0000    000a    4343    542d    363a    3330    0a00
          \0  \0  \0  \0  \0  \n   C   C   T   -   6   :   3   0  \n
0000217

% cmp -l zoneinfo_fix_gcc.*/Indian/Cocos
    47 132 133
    48 334 150
    51 114 103
    52 115 103



More information about the tz mailing list