Print this page
10107 librpcsvc needs smatch fixes


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 #pragma ident   "%Z%%M% %I%     %E% SMI"
  23 
  24 /*
  25  * rusers_simple.c
  26  * These are the "easy to use" interfaces to rusers.
  27  *
  28  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  29  * Use is subject to license terms.
  30  */
  31 




  32 #include <string.h>
  33 #include <rpc/rpc.h>
  34 #include <rpcsvc/rusers.h>
  35 #include <stdlib.h>
  36 
  37 int
  38 rusers3(host, uap)
  39         char *host;
  40         utmp_array *uap;
  41 {
  42         struct utmpidlearr up;
  43 
  44         if (rpc_call(host, RUSERSPROG, RUSERSVERS_3, RUSERSPROC_NAMES,
  45                         xdr_void, (char *) NULL,
  46                         xdr_utmp_array, (char *) uap, (char *) NULL) != 0) {
  47                 /*
  48                  * If version 3 isn't available, try version 2.  We'll have to
  49                  * convert a utmpidlearr structure into a utmp_array.
  50                  */
  51                 up.uia_cnt = 0;


  68                                 i < up.uia_cnt; rutp++, i++) {
  69                                 rutp->ut_line = (char *)malloc(sizeof
  70                                         (forsize.ut_line)+1);
  71                                 rutp->ut_user = (char *)malloc(sizeof
  72                                         (forsize.ut_name)+1);
  73                                 rutp->ut_host = (char *)malloc(sizeof
  74                                         (forsize.ut_host)+1);
  75                                 if (rutp->ut_line == NULL ||
  76                                         rutp->ut_user == NULL ||
  77                                         rutp->ut_host == NULL) {
  78 
  79                                         while (--rutp >= uap->utmp_array_val) {
  80                                                 free(rutp->ut_line);
  81                                                 free(rutp->ut_user);
  82                                                 free(rutp->ut_host);
  83                                         }
  84                                         free(uap->utmp_array_val);
  85                                         xdr_free(xdr_utmpidlearr, (char *)&up);
  86                                         return (-1);
  87                                 }
  88                                 strncpy(rutp->ut_line,
  89                                         up.uia_arr[i]->ui_utmp.ut_line,
  90                                         sizeof (forsize.ut_line)+1);
  91                                 strncpy(rutp->ut_user,
  92                                         up.uia_arr[i]->ui_utmp.ut_name,
  93                                         sizeof (forsize.ut_name)+1);
  94                                 strncpy(rutp->ut_host,
  95                                         up.uia_arr[i]->ui_utmp.ut_host,
  96                                         sizeof (forsize.ut_host)+1);
  97                                 rutp->ut_idle = up.uia_arr[i]->ui_idle;
  98                                 rutp->ut_time = up.uia_arr[i]->ui_utmp.ut_time;
  99                                 rutp->ut_type = RUSERS_USER_PROCESS;
 100                                                         /* assume this */
 101                         }
 102                         xdr_free(xdr_utmpidlearr, (char *)&up);
 103                 }
 104         }
 105         return (0);
 106 }
 107 
 108 int
 109 rnusers(host)
 110         char *host;
 111 {
 112         int nusers;
 113 
 114         if (rpc_call(host, RUSERSPROG, RUSERSVERS_3, RUSERSPROC_NUM,


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */

  22 
  23 /*
  24  * rusers_simple.c
  25  * These are the "easy to use" interfaces to rusers.
  26  *
  27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 /*
  32  * Copyright (c) 2018, Joyent, Inc.
  33  */
  34 
  35 #include <string.h>
  36 #include <rpc/rpc.h>
  37 #include <rpcsvc/rusers.h>
  38 #include <stdlib.h>
  39 
  40 int
  41 rusers3(host, uap)
  42         char *host;
  43         utmp_array *uap;
  44 {
  45         struct utmpidlearr up;
  46 
  47         if (rpc_call(host, RUSERSPROG, RUSERSVERS_3, RUSERSPROC_NAMES,
  48                         xdr_void, (char *) NULL,
  49                         xdr_utmp_array, (char *) uap, (char *) NULL) != 0) {
  50                 /*
  51                  * If version 3 isn't available, try version 2.  We'll have to
  52                  * convert a utmpidlearr structure into a utmp_array.
  53                  */
  54                 up.uia_cnt = 0;


  71                                 i < up.uia_cnt; rutp++, i++) {
  72                                 rutp->ut_line = (char *)malloc(sizeof
  73                                         (forsize.ut_line)+1);
  74                                 rutp->ut_user = (char *)malloc(sizeof
  75                                         (forsize.ut_name)+1);
  76                                 rutp->ut_host = (char *)malloc(sizeof
  77                                         (forsize.ut_host)+1);
  78                                 if (rutp->ut_line == NULL ||
  79                                         rutp->ut_user == NULL ||
  80                                         rutp->ut_host == NULL) {
  81 
  82                                         while (--rutp >= uap->utmp_array_val) {
  83                                                 free(rutp->ut_line);
  84                                                 free(rutp->ut_user);
  85                                                 free(rutp->ut_host);
  86                                         }
  87                                         free(uap->utmp_array_val);
  88                                         xdr_free(xdr_utmpidlearr, (char *)&up);
  89                                         return (-1);
  90                                 }
  91                                 (void) strncpy(rutp->ut_line,
  92                                         up.uia_arr[i]->ui_utmp.ut_line,
  93                                         sizeof (forsize.ut_line)+1);
  94                                 (void) strncpy(rutp->ut_user,
  95                                         up.uia_arr[i]->ui_utmp.ut_name,
  96                                         sizeof (forsize.ut_name)+1);
  97                                 (void) strncpy(rutp->ut_host,
  98                                         up.uia_arr[i]->ui_utmp.ut_host,
  99                                         sizeof (forsize.ut_host)+1);
 100                                 rutp->ut_idle = up.uia_arr[i]->ui_idle;
 101                                 rutp->ut_time = up.uia_arr[i]->ui_utmp.ut_time;
 102                                 rutp->ut_type = RUSERS_USER_PROCESS;
 103                                                         /* assume this */
 104                         }
 105                         xdr_free(xdr_utmpidlearr, (char *)&up);
 106                 }
 107         }
 108         return (0);
 109 }
 110 
 111 int
 112 rnusers(host)
 113         char *host;
 114 {
 115         int nusers;
 116 
 117         if (rpc_call(host, RUSERSPROG, RUSERSVERS_3, RUSERSPROC_NUM,