@@ -42,7 +42,7 @@ void rev_str(char *str) {
42
42
int get_timezone_offset (char *timezone) {
43
43
(void )timezone;
44
44
45
- unsigned char hdr[TIMEZONE_HDR_SIZE];
45
+ unsigned char hdr[TIMEZONE_HDR_SIZE + 1 ];
46
46
47
47
int32_t magic;
48
48
unsigned char version;
@@ -76,16 +76,16 @@ int get_timezone_offset(char *timezone) {
76
76
// for `tzfile`
77
77
magic = (hdr[0 ] << 24 ) | (hdr[1 ] << 16 ) | (hdr[2 ] << 8 ) | hdr[3 ];
78
78
version = hdr[4 ];
79
- for (i = 5 ; i <= 20 ; i++) {
79
+ for (i = 5 ; i < 21 ; i++) {
80
80
tmp = (tmp << 8 ) | hdr[i];
81
81
}
82
82
reserved = tmp;
83
- tzh_ttisutcnt = (hdr[20 ] << 24 ) | (hdr[21 ] << 16 ) | (hdr[22 ] << 8 ) | hdr[23 ];
84
- tzh_ttisstdcnt = (hdr[24 ] << 24 ) | (hdr[25 ] << 16 ) | (hdr[26 ] << 8 ) | hdr[27 ];
85
- tzh_leapcnt = (hdr[28 ] << 24 ) | (hdr[29 ] << 16 ) | (hdr[30 ] << 8 ) | hdr[31 ];
86
- tzh_timecnt = (hdr[32 ] << 24 ) | (hdr[33 ] << 16 ) | (hdr[34 ] << 8 ) | hdr[35 ];
87
- tzh_typecnt = (hdr[36 ] << 24 ) | (hdr[37 ] << 16 ) | (hdr[38 ] << 8 ) | hdr[39 ];
88
- tzh_charcnt = (hdr[40 ] << 24 ) | (hdr[41 ] << 16 ) | (hdr[42 ] << 8 ) | hdr[43 ];
83
+ tzh_ttisutcnt = (hdr[21 ] << 24 ) | (hdr[22 ] << 16 ) | (hdr[23 ] << 8 ) | hdr[24 ];
84
+ tzh_ttisstdcnt = (hdr[25 ] << 24 ) | (hdr[26 ] << 16 ) | (hdr[27 ] << 8 ) | hdr[28 ];
85
+ tzh_leapcnt = (hdr[29 ] << 24 ) | (hdr[30 ] << 16 ) | (hdr[31 ] << 8 ) | hdr[32 ];
86
+ tzh_timecnt = (hdr[33 ] << 24 ) | (hdr[34 ] << 16 ) | (hdr[35 ] << 8 ) | hdr[36 ];
87
+ tzh_typecnt = (hdr[37 ] << 24 ) | (hdr[38 ] << 16 ) | (hdr[39 ] << 8 ) | hdr[40 ];
88
+ tzh_charcnt = (hdr[41 ] << 24 ) | (hdr[42 ] << 16 ) | (hdr[43 ] << 8 ) | hdr[44 ];
89
89
(void )tzh_ttisutcnt;
90
90
(void )tzh_ttisstdcnt;
91
91
(void )tzh_leapcnt;
@@ -101,7 +101,7 @@ int get_timezone_offset(char *timezone) {
101
101
}
102
102
103
103
// according to `tzfile`, 15 bytes should be 0
104
- if (( reserved ^ 0x00 ) != 0 ) {
104
+ if (reserved != 0 ) {
105
105
return 0 ;
106
106
}
107
107
0 commit comments