Print this page
574 Minor issues in usr/src/cmd/format/startup.c

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/format/startup.c
          +++ new/usr/src/cmd/format/startup.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
       22 + * Copyright (c) 2012 Nexenta System Inc.
       23 + *
  22   24   * Copyright (c) 2011 Gary Mills
  23   25   *
  24   26   * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25   27   */
  26   28  
  27   29  /*
  28   30   * This file contains the code to perform program startup.  This
  29   31   * includes reading the data file and the search for disks.
  30   32   */
  31   33  #include "global.h"
↓ open down ↓ 2923 lines elided ↑ open up ↑
2955 2957          arglist[diskno] = NULL;
2956 2958  }
2957 2959  
2958 2960  #define DISK_PREFIX     "/dev/rdsk/"
2959 2961  
2960 2962  /*
2961 2963   * This Function checks if the non-conventional name is a a link to
2962 2964   * one of the conventional whole disk name.
2963 2965   */
2964 2966  static int
2965      -name_represents_wholedisk(name)
2966      -char    *name;
     2967 +name_represents_wholedisk(char  *name)
2967 2968  {
2968 2969          char    symname[MAXPATHLEN];
2969 2970          char    localname[MAXPATHLEN];
2970 2971          char    *nameptr;
     2972 +        ssize_t symname_size;
     2973 +        size_t disk_prefix_len = strlen(DISK_PREFIX);
2971 2974  
     2975 +        if (strlcpy(localname, name, MAXPATHLEN) >= MAXPATHLEN)
     2976 +                return (1);     /* buffer overflow, reject this name */
2972 2977  
2973      -        (void) memset(symname, 0, MAXPATHLEN);
2974      -        (void) memset(localname, 0, MAXPATHLEN);
2975      -        (void) strcpy(localname, name);
2976      -
2977      -        while (readlink(localname, symname, MAXPATHLEN) != -1) {
     2978 +        while ((symname_size = readlink(localname, symname, MAXPATHLEN - 1)) != -1) {
     2979 +                symname[symname_size] = '\0';
2978 2980                  nameptr = symname;
2979      -                if (strncmp(symname, DISK_PREFIX, strlen(DISK_PREFIX)) == 0)
2980      -                        nameptr += strlen(DISK_PREFIX);
2981      -                if (conventional_name(nameptr)) {
2982      -                        if (whole_disk_name(nameptr))
2983      -                                return (0);
2984      -                        else
2985      -                                return (1);
2986      -                }
     2981 +                if (strncmp(symname, DISK_PREFIX, disk_prefix_len) == 0)
     2982 +                        nameptr += disk_prefix_len;
     2983 +                if (conventional_name(nameptr))
     2984 +                        return (!whole_disk_name(nameptr));
2987 2985                  (void) strcpy(localname, symname);
2988      -                (void) memset(symname, 0, MAXPATHLEN);
2989 2986          }
2990 2987          return (0);
2991 2988  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX