Print this page
9644 Double-free in crypto tests on failure
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Mike Zeller <mike.zeller@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/crypto-tests/tests/common/cryptotest_kcf.c
          +++ new/usr/src/test/crypto-tests/tests/common/cryptotest_kcf.c
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       14 + * Copyright 2018, Joyent, Inc.
  14   15   */
  15   16  
  16   17  #include <fcntl.h>
  17   18  #include <strings.h>
  18   19  #include <unistd.h>
  19   20  #include <errno.h>
  20   21  #include <stdio.h>
  21   22  #include <stdlib.h>
  22   23  
  23   24  #include "cryptotest.h"
↓ open down ↓ 103 lines elided ↑ open up ↑
 127  128  
 128  129          bzero(&get_number, sizeof (get_number));
 129  130  
 130  131          get_number.pn_mechanism_string = op->mechname;
 131  132          get_number.pn_mechanism_len = strlen(op->mechname) + 1;
 132  133  
 133  134          if (kcf_do_ioctl(CRYPTO_GET_MECHANISM_NUMBER,
 134  135              (uint_t *)&get_number, "get_mech_info") != CRYPTO_SUCCESS) {
 135  136                  (void) fprintf(stderr, "failed to resolve mechanism name %s\n",
 136  137                      op->mechname);
 137      -                (void) cryptotest_close(op);
 138  138                  return (CTEST_NAME_RESOLVE_FAILED);
 139  139          }
 140  140          op->mech = get_number.pn_internal_number;
 141  141          return (CRYPTO_SUCCESS);
 142  142  }
 143  143  
 144  144  int
 145  145  get_hsession_by_mech(crypto_op_t *op)
 146  146  {
 147  147          crypto_by_mech_t mech;
↓ open down ↓ 3 lines elided ↑ open up ↑
 151  151          mech.mech_type = op->mech;
 152  152          mech.mech_fg = op->fg;
 153  153  
 154  154          rv = kcf_do_ioctl(CRYPTO_GET_PROVIDER_BY_MECH, (uint_t *)&mech,
 155  155              "get_hsession_by_mech");
 156  156  
 157  157          if (rv != 0 || mech.rv != CRYPTO_SUCCESS) {
 158  158                  (void) fprintf(stderr,
 159  159                      "could not find provider for mechanism %llu\n",
 160  160                      mech.mech_type);
 161      -                (void) cryptotest_close(op);
 162  161                  return (CTEST_MECH_NO_PROVIDER);
 163  162          }
 164  163  
 165  164          op->hsession = mech.session_id;
 166  165  
 167  166          return (CRYPTO_SUCCESS);
 168  167  }
 169  168  
 170  169  /*
 171  170   * CRYPTO_MAC_* functions
↓ open down ↓ 207 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX