aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2022-07-14 04:42:06 +0000
committerCy Schubert <cy@FreeBSD.org>2022-07-22 13:04:07 +0000
commiteeadef8fd52388bb9345df0ef472e0e7feca4afa (patch)
treed33488de1fc02a23eae7ba5c40a69cffbff22952
parent7a18eb78b281cac45c89fa57a7ac0e592aca1103 (diff)
telnet: Fix telnet segfault when invalid set or help help commands
Silently ignore invalid set ' ' and invalid help help commands. This is the same fix applied by NetBSD in hg commit 1019940:4f248823eaff. PR: 265097 Reported by: Simon Josefsson <simon@josefsson.org> Obtained from: NetBSD hg commit 1019940:4f248823eaff NetBSD PR/56918 (cherry picked from commit a7399ea2dd7810e76dcfd52248764cb8004d49a4)
-rw-r--r--contrib/telnet/telnet/commands.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c
index 21e973209d9b..fd4597941724 100644
--- a/contrib/telnet/telnet/commands.c
+++ b/contrib/telnet/telnet/commands.c
@@ -938,7 +938,7 @@ setcmd(int argc, char *argv[])
}
ct = getset(argv[1]);
- if (ct == 0) {
+ if (ct == 0 || !(ct->name && ct->name[0] != ' ')) {
c = GETTOGGLE(argv[1]);
if (c == 0) {
fprintf(stderr, "'%s': unknown argument ('set ?' for help).\n",
@@ -1014,7 +1014,7 @@ unsetcmd(int argc, char *argv[])
while (argc--) {
name = *argv++;
ct = getset(name);
- if (ct == 0) {
+ if (ct == 0 || !(ct->name && ct->name[0] != ' ')) {
c = GETTOGGLE(name);
if (c == 0) {
fprintf(stderr, "'%s': unknown argument ('unset ?' for help).\n",
@@ -2694,7 +2694,7 @@ help(int argc, char *argv[])
printf("?Ambiguous help command %s\n", arg);
else if (c == (Command *)0)
printf("?Invalid help command %s\n", arg);
- else
+ else if (c->help)
printf("%s\n", c->help);
}
return 0;