commit fe5f2ba3501c76178f9a88090d49414deb503bba
parent 9974e6b7651fc96216e9c21c780432af7b36e5e9
Author: Naveen Narayanan <zerous@nocebo.space>
Date: Tue, 12 Oct 2021 03:05:53 +0200
Remove sanity ;)
Diffstat:
1 file changed, 0 insertions(+), 12 deletions(-)
diff --git a/finger.c b/finger.c
@@ -29,19 +29,16 @@ cred(char *input, char *username, char *hostname)
fprintf(stderr, "hostname not found\n");
return 0;
}
-
if (a - input >= 32) {
fprintf(stderr, "username too long\n");
return 0;
}
memcpy(username, input, a - input);
-
if (strlen(a+1) > MAXHOSTNAMELEN) {
fprintf(stderr, "hostname too long\n");
return 0;
}
strcpy(hostname, a+1);
-
return 1;
}
@@ -60,19 +57,15 @@ main(int argc, char **argv)
if (argc != 2)
usage();
-
if (!cred(argv[1], user, hostname))
usage();
-
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
-
if ((status = getaddrinfo(hostname, "finger", &hints, &res)) != 0) {
fprintf(stderr, "getaddrinfo failed: %s\n", gai_strerror(status));
err = 1;
goto err1;
}
-
ulen = strlen(user);
for (p = res; p != NULL; p = p->ai_next) {
sockfd = socket(res->ai_family, res->ai_socktype,
@@ -83,19 +76,16 @@ main(int argc, char **argv)
err = 1;
goto err2;
}
-
if (connect(sockfd, res->ai_addr, res->ai_addrlen) == -1) {
fprintf(stderr, "connect failed: %s\n",
strerror(errno));
err = 1;
goto err3;
}
-
memcpy(msg, user, ulen);
msg[ulen] = '\r';
msg[ulen+1] = '\n';
len = ulen+2;
-
do {
n = send(sockfd, msg, len, 0);
if (n == -1) {
@@ -106,7 +96,6 @@ main(int argc, char **argv)
len -= n;
msg += n;
} while (len > 0);
-
msg = buf;
printf("[%s]\n", hostname);
do {
@@ -122,7 +111,6 @@ main(int argc, char **argv)
msg = buf;
} while (n > 0);
}
-
err3:
close(sockfd);
err2: