Print this page
10124 smatch fixes for cryptoadm


   5  * Common Development and Distribution License (the "License").
   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  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 



  25 
  26 #include <fcntl.h>
  27 #include <stdio.h>
  28 #include <stdlib.h>
  29 #include <strings.h>
  30 #include <unistd.h>
  31 #include <locale.h>
  32 #include <libgen.h>
  33 #include <sys/types.h>
  34 #include <zone.h>
  35 #include <sys/crypto/ioctladmin.h>
  36 #include <cryptoutil.h>
  37 #include "cryptoadm.h"
  38 
  39 #define REQ_ARG_CNT     2
  40 
  41 /* subcommand index */
  42 enum subcommand_index {
  43         CRYPTO_LIST,
  44         CRYPTO_DISABLE,


1285                 /* get kernel software providers from kernel ioctl */
1286                 crypto_get_soft_list_t          *psoftlist_kernel = NULL;
1287                 uint_t                          sl_soft_count;
1288                 char                            *psoftname;
1289                 entrylist_t                     *pdevlist_conf = NULL;
1290                 entrylist_t                     *psoftlist_conf = NULL;
1291 
1292                 if (get_soft_list(&psoftlist_kernel) == FAILURE) {
1293                         cryptoerror(LOG_ERR, gettext("Failed to retrieve the "
1294                             "software provider list from kernel."));
1295                         rc = FAILURE;
1296                 } else {
1297                         sl_soft_count = psoftlist_kernel->sl_soft_count;
1298 
1299                         if (get_kcfconf_info(&pdevlist_conf, &psoftlist_conf)
1300                             == FAILURE) {
1301                                 cryptoerror(LOG_ERR,
1302                                     "failed to retrieve the providers' "
1303                                     "information from file kcf.conf - %s.",
1304                                     _PATH_KCF_CONF);
1305                                 free(psoftlist_kernel);
1306                                 rc = FAILURE;
1307                         } else {
1308 
1309                                 for (i = 0,
1310                                     psoftname = psoftlist_kernel->sl_soft_names;
1311                                     i < sl_soft_count;
1312                                     ++i, psoftname += strlen(psoftname) + 1) {
1313                                         pent = getent_kef(psoftname,
1314                                             pdevlist_conf, psoftlist_conf);
1315                                         (void) printf("\t%s%s\n", psoftname,
1316                                             (pent == NULL) || (pent->load) ?
1317                                             "" : gettext(" (inactive)"));
1318                                 }
1319                                 free_entrylist(pdevlist_conf);
1320                                 free_entrylist(psoftlist_conf);
1321                         }
1322                         free(psoftlist_kernel);
1323                 }
1324 
1325         } else {




   5  * Common Development and Distribution License (the "License").
   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  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 
  25 /*
  26  * Copyright (c) 2018, Joyent, Inc.
  27  */
  28 
  29 #include <fcntl.h>
  30 #include <stdio.h>
  31 #include <stdlib.h>
  32 #include <strings.h>
  33 #include <unistd.h>
  34 #include <locale.h>
  35 #include <libgen.h>
  36 #include <sys/types.h>
  37 #include <zone.h>
  38 #include <sys/crypto/ioctladmin.h>
  39 #include <cryptoutil.h>
  40 #include "cryptoadm.h"
  41 
  42 #define REQ_ARG_CNT     2
  43 
  44 /* subcommand index */
  45 enum subcommand_index {
  46         CRYPTO_LIST,
  47         CRYPTO_DISABLE,


1288                 /* get kernel software providers from kernel ioctl */
1289                 crypto_get_soft_list_t          *psoftlist_kernel = NULL;
1290                 uint_t                          sl_soft_count;
1291                 char                            *psoftname;
1292                 entrylist_t                     *pdevlist_conf = NULL;
1293                 entrylist_t                     *psoftlist_conf = NULL;
1294 
1295                 if (get_soft_list(&psoftlist_kernel) == FAILURE) {
1296                         cryptoerror(LOG_ERR, gettext("Failed to retrieve the "
1297                             "software provider list from kernel."));
1298                         rc = FAILURE;
1299                 } else {
1300                         sl_soft_count = psoftlist_kernel->sl_soft_count;
1301 
1302                         if (get_kcfconf_info(&pdevlist_conf, &psoftlist_conf)
1303                             == FAILURE) {
1304                                 cryptoerror(LOG_ERR,
1305                                     "failed to retrieve the providers' "
1306                                     "information from file kcf.conf - %s.",
1307                                     _PATH_KCF_CONF);

1308                                 rc = FAILURE;
1309                         } else {
1310 
1311                                 for (i = 0,
1312                                     psoftname = psoftlist_kernel->sl_soft_names;
1313                                     i < sl_soft_count;
1314                                     ++i, psoftname += strlen(psoftname) + 1) {
1315                                         pent = getent_kef(psoftname,
1316                                             pdevlist_conf, psoftlist_conf);
1317                                         (void) printf("\t%s%s\n", psoftname,
1318                                             (pent == NULL) || (pent->load) ?
1319                                             "" : gettext(" (inactive)"));
1320                                 }
1321                                 free_entrylist(pdevlist_conf);
1322                                 free_entrylist(psoftlist_conf);
1323                         }
1324                         free(psoftlist_kernel);
1325                 }
1326 
1327         } else {