Print this page
10107 librpcsvc needs smatch fixes
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/librpcsvc/common/rusers_simple.c
+++ new/usr/src/lib/librpcsvc/common/rusers_simple.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 -#pragma ident "%Z%%M% %I% %E% SMI"
23 22
24 23 /*
25 24 * rusers_simple.c
26 25 * These are the "easy to use" interfaces to rusers.
27 26 *
28 27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
29 28 * Use is subject to license terms.
30 29 */
31 30
31 +/*
32 + * Copyright (c) 2018, Joyent, Inc.
33 + */
34 +
32 35 #include <string.h>
33 36 #include <rpc/rpc.h>
34 37 #include <rpcsvc/rusers.h>
35 38 #include <stdlib.h>
36 39
37 40 int
38 41 rusers3(host, uap)
39 42 char *host;
40 43 utmp_array *uap;
41 44 {
42 45 struct utmpidlearr up;
43 46
44 47 if (rpc_call(host, RUSERSPROG, RUSERSVERS_3, RUSERSPROC_NAMES,
45 48 xdr_void, (char *) NULL,
46 49 xdr_utmp_array, (char *) uap, (char *) NULL) != 0) {
47 50 /*
48 51 * If version 3 isn't available, try version 2. We'll have to
49 52 * convert a utmpidlearr structure into a utmp_array.
50 53 */
51 54 up.uia_cnt = 0;
52 55 up.uia_arr = NULL;
53 56 if (rusers(host, &up) != 0)
54 57 return (-1);
55 58 else {
56 59 int i;
57 60 struct ru_utmp forsize;
58 61 rusers_utmp *rutp;
59 62
60 63 uap->utmp_array_val = (rusers_utmp *)malloc(up.uia_cnt
61 64 * sizeof (rusers_utmp));
62 65 if (uap->utmp_array_val == NULL) {
63 66 xdr_free(xdr_utmpidlearr, (char *)&up);
64 67 return (-1);
65 68 }
66 69 uap->utmp_array_len = up.uia_cnt;
67 70 for (rutp = uap->utmp_array_val, i = 0;
68 71 i < up.uia_cnt; rutp++, i++) {
69 72 rutp->ut_line = (char *)malloc(sizeof
70 73 (forsize.ut_line)+1);
71 74 rutp->ut_user = (char *)malloc(sizeof
72 75 (forsize.ut_name)+1);
73 76 rutp->ut_host = (char *)malloc(sizeof
74 77 (forsize.ut_host)+1);
75 78 if (rutp->ut_line == NULL ||
76 79 rutp->ut_user == NULL ||
77 80 rutp->ut_host == NULL) {
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
78 81
79 82 while (--rutp >= uap->utmp_array_val) {
80 83 free(rutp->ut_line);
81 84 free(rutp->ut_user);
82 85 free(rutp->ut_host);
83 86 }
84 87 free(uap->utmp_array_val);
85 88 xdr_free(xdr_utmpidlearr, (char *)&up);
86 89 return (-1);
87 90 }
88 - strncpy(rutp->ut_line,
91 + (void) strncpy(rutp->ut_line,
89 92 up.uia_arr[i]->ui_utmp.ut_line,
90 93 sizeof (forsize.ut_line)+1);
91 - strncpy(rutp->ut_user,
94 + (void) strncpy(rutp->ut_user,
92 95 up.uia_arr[i]->ui_utmp.ut_name,
93 96 sizeof (forsize.ut_name)+1);
94 - strncpy(rutp->ut_host,
97 + (void) strncpy(rutp->ut_host,
95 98 up.uia_arr[i]->ui_utmp.ut_host,
96 99 sizeof (forsize.ut_host)+1);
97 100 rutp->ut_idle = up.uia_arr[i]->ui_idle;
98 101 rutp->ut_time = up.uia_arr[i]->ui_utmp.ut_time;
99 102 rutp->ut_type = RUSERS_USER_PROCESS;
100 103 /* assume this */
101 104 }
102 105 xdr_free(xdr_utmpidlearr, (char *)&up);
103 106 }
104 107 }
105 108 return (0);
106 109 }
107 110
108 111 int
109 112 rnusers(host)
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
110 113 char *host;
111 114 {
112 115 int nusers;
113 116
114 117 if (rpc_call(host, RUSERSPROG, RUSERSVERS_3, RUSERSPROC_NUM,
115 118 xdr_void, (char *) NULL,
116 119 xdr_u_int, (char *) &nusers, (char *) NULL) != 0) {
117 120 if (rpc_call(host, RUSERSPROG, RUSERSVERS_IDLE, RUSERSPROC_NUM,
118 121 xdr_void, (char *) NULL,
119 122 xdr_u_int, (char *) &nusers, (char *) NULL) != 0)
120 - return (-1);
123 + return (-1);
121 124 }
122 125 return (nusers);
123 126 }
124 127
125 128 enum clnt_stat
126 129 rusers(host, up)
127 130 char *host;
128 131 struct utmpidlearr *up;
129 132 {
130 133 return (rpc_call(host, RUSERSPROG, RUSERSVERS_IDLE, RUSERSPROC_NAMES,
131 134 xdr_void, (char *) NULL,
132 135 xdr_utmpidlearr, (char *) up, (char *) NULL));
133 136 }
134 137
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX