Print this page
new smatch

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/auditreduce/main.c
          +++ new/usr/src/cmd/auditreduce/main.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
       28 + * Copyright 2019 Joyent, Inc.
       29 + */
       30 +
       31 +/*
  28   32   * The Secure SunOS audit reduction tool - auditreduce.
  29   33   * Document SM0071 is the primary source of information on auditreduce.
  30   34   *
  31   35   * Composed of 4 source modules:
  32   36   * main.c - main driver.
  33   37   * option.c - command line option processing.
  34   38   * process.c - record/file/process functions.
  35   39   * time.c - date/time handling.
  36   40   *
  37   41   * Main(), write_header(), audit_stats(), and a_calloc()
↓ open down ↓ 202 lines elided ↑ open up ↑
 240  244                          pcbn->pcb_time = -1;
 241  245                          if (pipe(fildes)) {
 242  246                                  perror(gettext(
 243  247                                          "auditreduce: couldn't get a pipe"));
 244  248                                  return (-1);
 245  249                          }
 246  250                          /*
 247  251                           * Convert descriptors to streams.
 248  252                           */
 249  253                          if ((pcbn->pcb_fpr = fdopen(fildes[0], "r")) == NULL) {
 250      -        perror(gettext("auditreduce: couldn't get read stream for pipe"));
      254 +                                perror(gettext("auditreduce: couldn't get read "
      255 +                                    "stream for pipe"));
 251  256                                  return (-1);
 252  257                          }
 253  258                          if ((pcbn->pcb_fpw = fdopen(fildes[1], "w")) == NULL) {
 254      -        perror(gettext("auditreduce: couldn't get write stream for pipe"));
      259 +                                perror(gettext("auditreduce: couldn't get "
      260 +                                    "write stream for pipe"));
 255  261                                  return (-1);
 256  262                          }
 257  263                          if ((procno = fork()) == -1) {
 258  264                                  perror(gettext("auditreduce: fork failed"));
 259  265                                  return (-1);
 260  266                          }
 261  267                          /*
 262  268                           * Calculate the range of pcbs from audit_pcbs [] this
 263  269                           * branch of the tree will be responsible for.
 264  270                           */
↓ open down ↓ 128 lines elided ↑ open up ↑
 393  399  {
 394  400          int     j;
 395  401          audit_pcb_t *pcbt;
 396  402  
 397  403          /*
 398  404           * Do all pcbs in parent's group up to and including us
 399  405           */
 400  406          for (j = 0; j <= i; j++) {
 401  407                  pcbt = &pcb->pcb_below[j];
 402  408                  if (fclose(pcbt->pcb_fpr) == EOF) {
 403      -                        if (!f_quiet)
 404      -                perror(gettext("auditreduce: initial close on pipe failed"));
      409 +                        if (!f_quiet) {
      410 +                                perror(gettext("auditreduce: initial close "
      411 +                                    "on pipe failed"));
      412 +                        }
 405  413                  }
 406  414                  /*
 407  415                   * Free the buffer allocated to hold incoming records.
 408  416                   */
 409  417                  if (i != j) {
 410  418                          free(pcbt->pcb_rec);
 411  419                  }
 412  420          }
 413  421  }
 414  422  
↓ open down ↓ 4 lines elided ↑ open up ↑
 419  427   *      Closes the write stream on the pipe to the child since
 420  428   *      we will never use it.
 421  429   * .call        p_close(pcbn),
 422  430   * .arg pcbn    - ptr to pcb.
 423  431   * .ret void.
 424  432   */
 425  433  static void
 426  434  p_close(audit_pcb_t *pcbn)
 427  435  {
 428  436          if (fclose(pcbn->pcb_fpw) == EOF) {
 429      -                if (!f_quiet)
 430      -                perror(gettext("auditreduce: close for write pipe failed"));
      437 +                if (!f_quiet) {
      438 +                        perror(gettext("auditreduce: close for write "
      439 +                            "pipe failed"));
      440 +                }
 431  441          }
 432  442  }
 433  443  
 434  444  
 435  445  /*
 436  446   * .func        audit_stats - print statistics.
 437  447   * .desc        Print usage statistics for the user if the run fails.
 438  448   *      Tells them how many files they had and how many groups this
 439  449   *      totalled. Also tell them how many layers and processes the
 440  450   *      process tree had.
↓ open down ↓ 639 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX