Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/telnet Prevent crashes as shown in PR 56918.



details:   https://anonhg.NetBSD.org/src/rev/4f248823eaff
branches:  trunk
changeset: 368388:4f248823eaff
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Fri Jul 08 21:51:24 2022 +0000

description:
Prevent crashes as shown in PR 56918.

diffstat:

 usr.bin/telnet/commands.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r c2235754f48e -r 4f248823eaff usr.bin/telnet/commands.c
--- a/usr.bin/telnet/commands.c Fri Jul 08 21:19:06 2022 +0000
+++ b/usr.bin/telnet/commands.c Fri Jul 08 21:51:24 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: commands.c,v 1.79 2021/01/09 18:26:03 christos Exp $   */
+/*     $NetBSD: commands.c,v 1.80 2022/07/08 21:51:24 mlelstv Exp $    */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: commands.c,v 1.79 2021/01/09 18:26:03 christos Exp $");
+__RCSID("$NetBSD: commands.c,v 1.80 2022/07/08 21:51:24 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -952,7 +952,7 @@
     }
 
     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",
@@ -1028,7 +1028,7 @@
     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",
@@ -2453,7 +2453,7 @@
                        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;



Home | Main Index | Thread Index | Old Index