Skip to content

Commit

Permalink
correct extremely user-unfriendly error message on bad port
Browse files Browse the repository at this point in the history
("telnet localhost foo" when foo is invalid).
suggested by openbsd camp.
  • Loading branch information
itojun committed May 13, 2000
1 parent 2b64a91 commit dc1c573
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion freebsd2/usr.bin/telnet/commands.c
Expand Up @@ -2287,7 +2287,11 @@ tn(argc, argv)
hints.ai_protocol = 0;
hints.ai_flags = AI_CANONNAME;
error = getaddrinfo(hostname, portp, &hints, &res0);
if (error) {
if (error == EAI_SERVICE) {
fprintf(stderr, "tcp/%s: unknown service\n", portp);
setuid(getuid());
return 0;
} else if (error) {
fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
setuid(getuid());
return 0;
Expand Down
6 changes: 5 additions & 1 deletion freebsd3/usr.bin/telnet/commands.c
Expand Up @@ -2312,7 +2312,11 @@ tn(argc, argv)
hints.ai_protocol = 0;
hints.ai_flags = AI_CANONNAME;
error = getaddrinfo(hostname, portp, &hints, &res0);
if (error) {
if (error == EAI_SERVICE) {
fprintf(stderr, "tcp/%s: unknown service\n", portp);
setuid(getuid());
return 0;
} else if (error) {
fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
setuid(getuid());
return 0;
Expand Down
5 changes: 4 additions & 1 deletion netbsd/usr.bin/telnet/commands.c
Expand Up @@ -2328,7 +2328,10 @@ tn(argc, argv)
hints.ai_protocol = 0;
hints.ai_flags = AI_CANONNAME;
error = getaddrinfo(hostname, portp, &hints, &res0);
if (error) {
if (error == EAI_SERVICE) {
fprintf(stderr, "tcp/%s: unknown service\n", portp);
return 0;
} else if (error) {
fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
return 0;
}
Expand Down
8 changes: 7 additions & 1 deletion openbsd/usr.bin/telnet/commands.c
Expand Up @@ -2384,7 +2384,13 @@ tn(argc, argv)
telnetport = 1;
}
error = getaddrinfo(hostp, portp, &hints, &res0);
if (error) {
if (error == EAI_SERVICE) {
warn("tcp/%s: unknown service\n", portp);
herror(hostp);
seteuid(getuid());
setuid(getuid());
return 0;
} else if (error) {
warn("%s: %s", hostp, gai_strerror(error));
herror(hostp);
seteuid(getuid());
Expand Down

0 comments on commit dc1c573

Please sign in to comment.