Print this page
8226 missing boot environments cause bootadm list-menu to segfault

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/boot/bootadm/bootadm_loader.c
          +++ new/usr/src/cmd/boot/bootadm/bootadm_loader.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2012 Milan Jurik. All rights reserved.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  28   28   * Copyright 2016 Toomas Soome <tsoome@me.com>
       29 + * Copyright 2017 RackTop Systems.
  29   30   */
  30   31  
  31   32  /*
  32   33   * Loader menu management.
  33   34   */
  34   35  
  35   36  #include <stdio.h>
  36   37  #include <stdlib.h>
  37   38  #include <string.h>
  38   39  #include <wchar.h>
↓ open down ↓ 136 lines elided ↑ open up ↑
 175  176  
 176  177          for (i = 0; i < NUM_COLS; i++)
 177  178                  hdr->cols[i].width = len[i];
 178  179  }
 179  180  
 180  181  static void
 181  182  print_menu_nodes(boolean_t parsable, struct hdr_info *hdr,
 182  183      struct menu_lst *menu)
 183  184  {
 184  185          struct menu_entry  *entry;
 185      -        int i = -1;
      186 +        int i = 0;
 186  187          int rv;
 187  188          be_node_list_t *be_nodes, *be_node;
 188  189  
 189  190          rv = be_list(NULL, &be_nodes);
 190  191          if (rv != BE_SUCCESS)
 191  192                  return;
 192  193  
 193  194          STAILQ_FOREACH(entry, menu, next) {
 194      -                i++;
      195 +                boolean_t active = B_FALSE;
      196 +
 195  197                  for (be_node = be_nodes; be_node;
 196  198                      be_node = be_node->be_next_node)
 197  199                          if (strcmp(be_node->be_root_ds, entry->bootfs) == 0)
 198      -                                break;
      200 +                                if (be_node->be_active_on_boot)
      201 +                                        active = B_TRUE;
 199  202  
 200  203                  if (parsable)
 201  204                          (void) printf("%d;%s;%s;%s\n", i,
 202      -                            be_node->be_active_on_boot == B_TRUE? "*" : "-",
      205 +                            active == B_TRUE ? "*" : "-",
 203  206                              entry->bootfs, entry->title);
 204  207                  else
 205  208                          (void) printf("%-*d %-*s %-*s %-*s\n",
 206  209                              hdr->cols[0].width, i,
 207  210                              hdr->cols[1].width,
 208      -                            be_node->be_active_on_boot == B_TRUE? "*" : "-",
      211 +                            active == B_TRUE ? "*" : "-",
 209  212                              hdr->cols[2].width, entry->bootfs,
 210  213                              hdr->cols[3].width, entry->title);
      214 +
      215 +                i++;
 211  216          }
 212  217          be_free_list(be_nodes);
 213  218  }
 214  219  
 215  220  static void
 216  221  print_nodes(boolean_t parsable, struct menu_lst *menu)
 217  222  {
 218  223          struct hdr_info hdr;
 219  224  
 220  225          if (!parsable) {
↓ open down ↓ 1109 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX