Print this page
10119 audit(1) gets NULL check wrong

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/audit/audit.c
          +++ new/usr/src/cmd/audit/audit.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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   22  /*
  23   23   * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
       26 +/*
       27 + * Copyright (c) 2018, Joyent, Inc.
       28 + */
       29 +
  26   30  #include <fcntl.h>
  27   31  #include <libscf.h>
  28   32  #include <secdb.h>
  29   33  #include <stdlib.h>
  30   34  #include <stdio.h>
  31   35  #include <string.h>
  32   36  #include <sys/file.h>
  33   37  #include <sys/stat.h>
  34   38  #include <sys/types.h>
  35   39  #include <sys/wait.h>
↓ open down ↓ 189 lines elided ↑ open up ↑
 225  229                  if (!one_plugin_enabled) {
 226  230                          cval_str = kva_match(kvlist, "active");
 227  231                          if (atoi(cval_str) == 1) {
 228  232                                  one_plugin_enabled = B_TRUE;
 229  233                          }
 230  234                  }
 231  235  
 232  236                  if (strcmp((char *)&(*plugin_kva_ll).plugin_name,
 233  237                      "audit_binfile") == 0) {
 234  238                          cval_str = kva_match(kvlist, "p_dir");
 235      -                        if (*cval_str == '\0' || cval_str == NULL) {
      239 +                        if (cval_str == NULL || cval_str[0] == '\0') {
 236  240                                  (void) fprintf(stderr,
 237  241                                      gettext("%s: audit_binfile(5) \"p_dir:\" "
 238  242                                      "attribute empty\n"), progname);
 239  243                                  state = B_FALSE;
 240  244                          } else if (!contains_valid_dirs(cval_str)) {
 241  245                                  (void) fprintf(stderr,
 242  246                                      gettext("%s: audit_binfile(5) \"p_dir:\" "
 243  247                                      "attribute invalid\n"), progname);
 244  248                                  state = B_FALSE;
 245  249                          }
↓ open down ↓ 182 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX