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


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 




  26 #include <fcntl.h>
  27 #include <libscf.h>
  28 #include <secdb.h>
  29 #include <stdlib.h>
  30 #include <stdio.h>
  31 #include <string.h>
  32 #include <sys/file.h>
  33 #include <sys/stat.h>
  34 #include <sys/types.h>
  35 #include <sys/wait.h>
  36 #include <signal.h>
  37 #include <sys/param.h>
  38 #include <unistd.h>
  39 #include <bsm/audit.h>
  40 #include <bsm/libbsm.h>
  41 #include <locale.h>
  42 #include <zone.h>
  43 #include <audit_scf.h>
  44 
  45 #if !defined(TEXT_DOMAIN)


 215                 (void) fprintf(stderr,
 216                     gettext("Could not get plugin configuration.\n"));
 217                 exit(1);
 218         }
 219 
 220         plugin_kva_ll_head = plugin_kva_ll;
 221 
 222         while (plugin_kva_ll != NULL) {
 223                 kvlist = plugin_kva_ll->plugin_kva;
 224 
 225                 if (!one_plugin_enabled) {
 226                         cval_str = kva_match(kvlist, "active");
 227                         if (atoi(cval_str) == 1) {
 228                                 one_plugin_enabled = B_TRUE;
 229                         }
 230                 }
 231 
 232                 if (strcmp((char *)&(*plugin_kva_ll).plugin_name,
 233                     "audit_binfile") == 0) {
 234                         cval_str = kva_match(kvlist, "p_dir");
 235                         if (*cval_str == '\0' || cval_str == NULL) {
 236                                 (void) fprintf(stderr,
 237                                     gettext("%s: audit_binfile(5) \"p_dir:\" "
 238                                     "attribute empty\n"), progname);
 239                                 state = B_FALSE;
 240                         } else if (!contains_valid_dirs(cval_str)) {
 241                                 (void) fprintf(stderr,
 242                                     gettext("%s: audit_binfile(5) \"p_dir:\" "
 243                                     "attribute invalid\n"), progname);
 244                                 state = B_FALSE;
 245                         }
 246 
 247                         cval_str = kva_match(kvlist, "p_minfree");
 248                         cval_int = atoi(cval_str);
 249                         if (cval_int < 0 || cval_int > 100) {
 250                                 (void) fprintf(stderr,
 251                                     gettext("%s: audit_binfile(5) "
 252                                     "\"p_minfree:\" attribute invalid\n"),
 253                                     progname);
 254                                 state = B_FALSE;
 255                         }




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 #include <fcntl.h>
  31 #include <libscf.h>
  32 #include <secdb.h>
  33 #include <stdlib.h>
  34 #include <stdio.h>
  35 #include <string.h>
  36 #include <sys/file.h>
  37 #include <sys/stat.h>
  38 #include <sys/types.h>
  39 #include <sys/wait.h>
  40 #include <signal.h>
  41 #include <sys/param.h>
  42 #include <unistd.h>
  43 #include <bsm/audit.h>
  44 #include <bsm/libbsm.h>
  45 #include <locale.h>
  46 #include <zone.h>
  47 #include <audit_scf.h>
  48 
  49 #if !defined(TEXT_DOMAIN)


 219                 (void) fprintf(stderr,
 220                     gettext("Could not get plugin configuration.\n"));
 221                 exit(1);
 222         }
 223 
 224         plugin_kva_ll_head = plugin_kva_ll;
 225 
 226         while (plugin_kva_ll != NULL) {
 227                 kvlist = plugin_kva_ll->plugin_kva;
 228 
 229                 if (!one_plugin_enabled) {
 230                         cval_str = kva_match(kvlist, "active");
 231                         if (atoi(cval_str) == 1) {
 232                                 one_plugin_enabled = B_TRUE;
 233                         }
 234                 }
 235 
 236                 if (strcmp((char *)&(*plugin_kva_ll).plugin_name,
 237                     "audit_binfile") == 0) {
 238                         cval_str = kva_match(kvlist, "p_dir");
 239                         if (cval_str == NULL || cval_str[0] == '\0') {
 240                                 (void) fprintf(stderr,
 241                                     gettext("%s: audit_binfile(5) \"p_dir:\" "
 242                                     "attribute empty\n"), progname);
 243                                 state = B_FALSE;
 244                         } else if (!contains_valid_dirs(cval_str)) {
 245                                 (void) fprintf(stderr,
 246                                     gettext("%s: audit_binfile(5) \"p_dir:\" "
 247                                     "attribute invalid\n"), progname);
 248                                 state = B_FALSE;
 249                         }
 250 
 251                         cval_str = kva_match(kvlist, "p_minfree");
 252                         cval_int = atoi(cval_str);
 253                         if (cval_int < 0 || cval_int > 100) {
 254                                 (void) fprintf(stderr,
 255                                     gettext("%s: audit_binfile(5) "
 256                                     "\"p_minfree:\" attribute invalid\n"),
 257                                     progname);
 258                                 state = B_FALSE;
 259                         }