| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: finger.c,v 1.30 2016/09/05 00:40:28 sevan Exp $ */ | | 1 | /* $NetBSD: finger.c,v 1.31 2021/10/30 09:12:09 nia Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1989, 1993 | | 4 | * Copyright (c) 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. | | 8 | * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -42,27 +42,27 @@ | | | @@ -42,27 +42,27 @@ |
42 | * login time is < 6 days. | | 42 | * login time is < 6 days. |
43 | */ | | 43 | */ |
44 | | | 44 | |
45 | #include <sys/cdefs.h> | | 45 | #include <sys/cdefs.h> |
46 | #ifndef lint | | 46 | #ifndef lint |
47 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ | | 47 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ |
48 | The Regents of the University of California. All rights reserved."); | | 48 | The Regents of the University of California. All rights reserved."); |
49 | #endif /* not lint */ | | 49 | #endif /* not lint */ |
50 | | | 50 | |
51 | #ifndef lint | | 51 | #ifndef lint |
52 | #if 0 | | 52 | #if 0 |
53 | static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; | | 53 | static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; |
54 | #else | | 54 | #else |
55 | __RCSID("$NetBSD: finger.c,v 1.30 2016/09/05 00:40:28 sevan Exp $"); | | 55 | __RCSID("$NetBSD: finger.c,v 1.31 2021/10/30 09:12:09 nia Exp $"); |
56 | #endif | | 56 | #endif |
57 | #endif /* not lint */ | | 57 | #endif /* not lint */ |
58 | | | 58 | |
59 | /* | | 59 | /* |
60 | * Finger prints out information about users. It is not portable since | | 60 | * Finger prints out information about users. It is not portable since |
61 | * certain fields (e.g. the full user name, office, and phone numbers) are | | 61 | * certain fields (e.g. the full user name, office, and phone numbers) are |
62 | * extracted from the gecos field of the passwd file which other UNIXes | | 62 | * extracted from the gecos field of the passwd file which other UNIXes |
63 | * may not have or may use for other things. | | 63 | * may not have or may use for other things. |
64 | * | | 64 | * |
65 | * There are currently two output formats; the short format is one line | | 65 | * There are currently two output formats; the short format is one line |
66 | * per user and displays login name, tty, login time, real name, idle time, | | 66 | * per user and displays login name, tty, login time, real name, idle time, |
67 | * and either remote host information (default) or office location/phone | | 67 | * and either remote host information (default) or office location/phone |
68 | * number, depending on if -h or -o is used respectively. | | 68 | * number, depending on if -h or -o is used respectively. |
| @@ -216,28 +216,30 @@ loginlist(void) | | | @@ -216,28 +216,30 @@ loginlist(void) |
216 | } | | 216 | } |
217 | } | | 217 | } |
218 | | | 218 | |
219 | static void | | 219 | static void |
220 | userlist(int argc, char **argv) | | 220 | userlist(int argc, char **argv) |
221 | { | | 221 | { |
222 | PERSON *pn; | | 222 | PERSON *pn; |
223 | DBT data, key; | | 223 | DBT data, key; |
224 | struct passwd *pw; | | 224 | struct passwd *pw; |
225 | int r, seqflag, *used, *ip; | | 225 | int r, seqflag, *used, *ip; |
226 | char **ap, **nargv, **np, **p; | | 226 | char **ap, **nargv, **np, **p; |
227 | struct utmpentry *ep; | | 227 | struct utmpentry *ep; |
228 | | | 228 | |
229 | if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL || | | 229 | nargv = NULL; |
230 | (used = calloc(argc, sizeof(int))) == NULL) | | 230 | if (reallocarr(&nargv, argc + 1, sizeof(char *)) != 0) |
| | | 231 | err(1, NULL); |
| | | 232 | if ((used = calloc(argc, sizeof(int))) == NULL) |
231 | err(1, NULL); | | 233 | err(1, NULL); |
232 | | | 234 | |
233 | /* Pull out all network requests. */ | | 235 | /* Pull out all network requests. */ |
234 | for (ap = p = argv, np = nargv; *p; ++p) | | 236 | for (ap = p = argv, np = nargv; *p; ++p) |
235 | if (strchr(*p, '@')) | | 237 | if (strchr(*p, '@')) |
236 | *np++ = *p; | | 238 | *np++ = *p; |
237 | else | | 239 | else |
238 | *ap++ = *p; | | 240 | *ap++ = *p; |
239 | | | 241 | |
240 | *np++ = NULL; | | 242 | *np++ = NULL; |
241 | *ap++ = NULL; | | 243 | *ap++ = NULL; |
242 | | | 244 | |
243 | if (!*argv) | | 245 | if (!*argv) |