Module Name: src Committed By: mlelstv Date: Fri Jul 8 21:51:24 UTC 2022
Modified Files: src/usr.bin/telnet: commands.c Log Message: Prevent crashes as shown in PR 56918. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/usr.bin/telnet/commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/telnet/commands.c diff -u src/usr.bin/telnet/commands.c:1.79 src/usr.bin/telnet/commands.c:1.80 --- src/usr.bin/telnet/commands.c:1.79 Sat Jan 9 18:26:03 2021 +++ src/usr.bin/telnet/commands.c Fri Jul 8 21:51:24 2022 @@ -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 @@ 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", @@ -1028,7 +1028,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", @@ -2453,7 +2453,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;