Print this page
5679 be_sort_list(): Possible null pointer dereference

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/beadm/beadm.c
          +++ new/usr/src/cmd/beadm/beadm.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  28   28   * Copyright 2015 Toomas Soome <tsoome@me.com>
       29 + * Copyright 2015 Gary Mills
  29   30   */
  30   31  
  31   32  /*
  32   33   * System includes
  33   34   */
  34   35  
  35   36  #include <assert.h>
  36   37  #include <stdio.h>
  37   38  #include <strings.h>
  38   39  #include <libzfs.h>
↓ open down ↓ 1132 lines elided ↑ open up ↑
1171 1172                  be_name = argv[0];
1172 1173  
1173 1174          err = be_list(be_name, &be_nodes);
1174 1175  
1175 1176          switch (err) {
1176 1177          case BE_SUCCESS:
1177 1178                  /* the default sort is ascending date, no need to sort twice */
1178 1179                  if (order == BE_SORT_UNSPECIFIED)
1179 1180                          order = BE_SORT_DATE;
1180 1181  
1181      -                if (order != BE_SORT_DATE)
1182      -                        be_sort(&be_nodes, order);
     1182 +                if (order != BE_SORT_DATE) {
     1183 +                        err = be_sort(&be_nodes, order);
     1184 +                        if (err != BE_SUCCESS) {
     1185 +                                (void) fprintf(stderr, _("Unable to sort Boot "
     1186 +                                    "Environment\n"));
     1187 +                                (void) fprintf(stderr, "%s\n",
     1188 +                                    be_err_to_str(err));
     1189 +                                break;
     1190 +                        }
     1191 +                }
1183 1192  
1184 1193                  print_nodes(be_name, dsets, snaps, parsable, be_nodes);
1185 1194                  break;
1186 1195          case BE_ERR_BE_NOENT:
1187 1196                  if (be_name == NULL)
1188 1197                          (void) fprintf(stderr, _("No boot environments found "
1189 1198                              "on this system.\n"));
1190 1199                  else {
1191 1200                          (void) fprintf(stderr, _("%s does not exist or appear "
1192 1201                              "to be a valid BE.\nPlease check that the name of "
↓ open down ↓ 375 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX