Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2022 13:48:17 GMT
From:      Cy Schubert <cy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a7399ea2dd78 - main - telnet: Fix telnet segfault when invalid set or help help commands
Message-ID:  <202207151348.26FDmHSL006941@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=a7399ea2dd7810e76dcfd52248764cb8004d49a4

commit a7399ea2dd7810e76dcfd52248764cb8004d49a4
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2022-07-14 04:42:06 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2022-07-15 13:38:57 +0000

    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
    MFC after:      1 week
---
 contrib/telnet/telnet/commands.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c
index c52af2a81a67..6414a120ea92 100644
--- a/contrib/telnet/telnet/commands.c
+++ b/contrib/telnet/telnet/commands.c
@@ -939,7 +939,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",
@@ -1015,7 +1015,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",
@@ -2702,7 +2702,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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207151348.26FDmHSL006941>