Print this page
10110 get_tz_countries shouldn't check array for NULL

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzoneinfo/common/libzone.c
          +++ new/usr/src/lib/libzoneinfo/common/libzone.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       27 +/*
       28 + * Copyright (c) 2018, Joyent, Inc.
       29 + */
  28   30  
  29   31  #include <stdlib.h>
  30   32  #include <stdio.h>
  31   33  #include <string.h>
  32   34  #include <unistd.h>
  33   35  #include <sys/param.h>
  34   36  #include <sys/types.h>
  35   37  #include <sys/stat.h>
  36   38  #include <tzfile.h>
  37   39  #include <fcntl.h>
↓ open down ↓ 166 lines elided ↑ open up ↑
 204  206  get_tz_countries(struct tz_country **country, struct tz_continent *cont)
 205  207  {
 206  208          FILE *fp_zone, *fp_cc;
 207  209          char buff[BUFFLEN], ccbuf[_CCBUFLEN], *ptr;
 208  210          char *lp, *lptr, *lp_coord, *lp_cc, *lp_tz;     /* line pointer */
 209  211          struct tz_country *head = NULL, *prev = NULL, *next, *cp, *cp2;
 210  212          int sav_errno = 0, ncount, i;
 211  213          int cmp, status;
 212  214          size_t len, len_coord, len_ctnt;
 213  215  
 214      -        if (cont->ctnt_name == NULL) {
 215      -                errno = EINVAL;
 216      -                return (-1);
 217      -        }
 218  216          len_ctnt = strlen(cont->ctnt_name);
 219  217          ccbuf[0] = '\0';
 220  218  
 221  219          /* open zone_sun.tab and country.tab files */
 222  220          if ((fp_zone = fopen(ZONE_SUN_TAB, "r")) == NULL) {
 223  221                  /* fopen() sets errno */
 224  222                  return (-1);
 225  223          }
 226  224          if ((fp_cc = fopen(COUNTRY_TAB, "r")) == NULL) {
 227  225                  /* fopen() sets errno */
↓ open down ↓ 1162 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX