Print this page
10116 mech_dh needs smatch fixes

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/gss_mechs/mech_dh/dh_common/dh_template.c
          +++ new/usr/src/lib/gss_mechs/mech_dh/dh_common/dh_template.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   *      dh_template.c
  24   24   *
  25   25   *      Copyright (c) 1997, by Sun Microsystems, Inc.
  26   26   *      All rights reserved.
  27   27   */
  28   28  
  29      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       29 +/*
       30 + * Copyright (c) 2018, Joyent, Inc.
       31 + */
  30   32  
  31   33  #include <stdlib.h>
  32   34  #include <string.h>
  33   35  #include <syslog.h>
  34   36  #include <dh_gssapi.h>
  35   37  #include <dlfcn.h>
  36   38  #include "../dh_common/dh_common.h"
  37   39  
  38   40  extern int key_encryptsession_pk_g();
  39   41  extern int key_decryptsession_pk_g();
↓ open down ↓ 57 lines elided ↑ open up ↑
  97   99  static int
  98  100  dh_getpublickey(const char *remote, keylen_t keylen, algtype_t algtype,
  99  101                  char *pk, size_t pklen)
 100  102  {
 101  103          static mutex_t init_nis_pubkey_lock = DEFAULTMUTEX;
 102  104          static int init_nis_pubkey = 0;
 103  105          static int (*nis_call)();
 104  106          static const char NIS_SYMBOL[] = "__rpcsec_gss_is_server";
 105  107  
 106  108          if (!init_nis_pubkey) {
 107      -                mutex_lock(&init_nis_pubkey_lock);
      109 +                (void) mutex_lock(&init_nis_pubkey_lock);
 108  110                  if (!init_nis_pubkey) {
 109  111                          void *dlhandle = dlopen(0, RTLD_NOLOAD);
 110  112                          if (dlhandle == 0) {
 111  113                                  syslog(LOG_ERR, "dh: Could not dlopen "
 112  114                                      "in dh_getpublickey for %s. "
 113  115                                      "dlopen returned %s", remote, dlerror());
 114  116                          } else {
 115  117                                  nis_call = (int (*)())
 116  118                                          dlsym(dlhandle, NIS_SYMBOL);
 117  119                          }
 118  120                          init_nis_pubkey = 1;
 119  121                  }
 120      -                mutex_unlock(&init_nis_pubkey_lock);
      122 +                (void) mutex_unlock(&init_nis_pubkey_lock);
 121  123          }
 122  124          if (nis_call && (*nis_call)()) {
 123  125                  int key_cached;
 124  126                  return (__getpublickey_cached_g(remote, keylen, algtype,
 125  127                                              pk, pklen, &key_cached));
 126  128          }
 127  129  
 128  130          /*
 129  131           * If we're not being called by a nis plus server or that
 130  132           * server does not want to get the keys from the cache we
↓ open down ↓ 119 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX