@@ -42,7 +42,7 @@ void rev_str(char *str) {
4242int  get_timezone_offset (char  *timezone) {
4343  (void )timezone;
4444
45-   unsigned  char  hdr[TIMEZONE_HDR_SIZE];
45+   unsigned  char  hdr[TIMEZONE_HDR_SIZE +  1 ];
4646
4747  int32_t  magic;
4848  unsigned  char  version;
@@ -76,16 +76,16 @@ int get_timezone_offset(char *timezone) {
7676  //  for `tzfile`
7777  magic = (hdr[0 ] << 24 ) | (hdr[1 ] << 16 ) | (hdr[2 ] << 8 ) | hdr[3 ];
7878  version = hdr[4 ];
79-   for  (i = 5 ; i <=  20 ; i++) {
79+   for  (i = 5 ; i <  21 ; i++) {
8080    tmp = (tmp << 8 ) | hdr[i];
8181  }
8282  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 ];
8989  (void )tzh_ttisutcnt;
9090  (void )tzh_ttisstdcnt;
9191  (void )tzh_leapcnt;
@@ -101,7 +101,7 @@ int get_timezone_offset(char *timezone) {
101101  }
102102
103103  //  according to `tzfile`, 15 bytes should be 0
104-   if  (( reserved ^  0x00 )  != 0 ) {
104+   if  (reserved != 0 ) {
105105    return  0 ;
106106  }
107107
0 commit comments