summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-05-30 08:44:11 +0000
committerderaadt <deraadt@openbsd.org>1996-05-30 08:44:11 +0000
commitc549fc11440d8c1bf608fd5f69a238ca9abb5d8e (patch)
tree980b6d0680eeb025447fe8a0795ac7579bac91d3
parentwho wrote this code? nonblocking pipe, select, and then not deal with a (diff)
downloadwireguard-openbsd-c549fc11440d8c1bf608fd5f69a238ca9abb5d8e.tar.xz
wireguard-openbsd-c549fc11440d8c1bf608fd5f69a238ca9abb5d8e.zip
optimize something like "finger @@@@@@@@@@@@@cvs@@@@@@cvs@@@@@@cvs' to hit
fewer hosts. Basically, chew @ signs when possible.
-rw-r--r--libexec/fingerd/fingerd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c
index b3d0cc5f30a..04fac1d0538 100644
--- a/libexec/fingerd/fingerd.c
+++ b/libexec/fingerd/fingerd.c
@@ -39,7 +39,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)fingerd.c 5.6 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: fingerd.c,v 1.1.1.1 1995/10/18 08:43:15 deraadt Exp $";
+static char rcsid[] = "$Id: fingerd.c,v 1.2 1996/05/30 08:44:11 deraadt Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -53,6 +53,7 @@ main()
int p[2];
#define ENTRIES 50
char **ap, *av[ENTRIES + 1], line[1024], *strtok();
+ int i;
#ifdef LOGGING /* unused for now */
#include <netinet/in.h>
@@ -80,6 +81,15 @@ main()
lp = NULL;
}
+ for (i = 1; av[i]; i++) {
+ int l = strlen(av[i]);
+
+ while (av[i][l-1] == '@')
+ av[i][--l] = '\0';
+ if (av[i][0] == '\0')
+ av[i] = NULL;
+ }
+
if (pipe(p) < 0)
fatal("pipe");