From nobody Fri Jul 22 13:04:30 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lq8ly6yjHz4XC09; Fri, 22 Jul 2022 13:04:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lq8ly6Q7Sz3ByR; Fri, 22 Jul 2022 13:04:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658495070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yqw8jgJUfmwdT6rF2opgy/QhLdkVWmQETcLDMkDGGHY=; b=Dfxg242CTxyi4JGP8MIAT5WyjlMgZBSiqeZkmYRX0Nr+0hafQ71yfQtmp7MibEca3MFopF FKnlPwAWbk9HvBdlQIqiIPhYE/Bl41MvPQ4zsOiKxQFO0R4Awl05uJYrEVvFbWg3zo0+Yw slpN0lRDE3/rZr/baY5On109WMdh81+vfn38YRWEHX8wiZctgmifXGTD1I1gsGNpSbhJ+D MJpOyF8NcXwWB+8FE6s1sBUvNJ7wi2Dx+8J9O9lg1fxJJB6OggqtHrPpk4UKiHTkiBwRFr UBU+vRCo540jHkIFYn1Q7Y/xkUkrb3BCEkSGv0hT3/ZZg6DrPWBGusyvSqM8ag== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Lq8ly5RSnz12Hh; Fri, 22 Jul 2022 13:04:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26MD4Udf005023; Fri, 22 Jul 2022 13:04:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26MD4UEf005022; Fri, 22 Jul 2022 13:04:30 GMT (envelope-from git) Date: Fri, 22 Jul 2022 13:04:30 GMT Message-Id: <202207221304.26MD4UEf005022@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: eeadef8fd523 - stable/12 - telnet: Fix telnet segfault when invalid set or help help commands List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: eeadef8fd52388bb9345df0ef472e0e7feca4afa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658495070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yqw8jgJUfmwdT6rF2opgy/QhLdkVWmQETcLDMkDGGHY=; b=Z1xEyXL5Wgtek4V6jj5wOAuFIcok2VPY6FnKMzQPsTfvcHNvmx9yagmPID1ZoSr28eaZjL 7815QcRUc1HWdiMYXAGRKkj7JioSMeHNvPNdMvJucGFFybukphg23j9iOw5aqm+b8mppqX oWjLadUahLBMeTZCBpdVyjEKWfm6YXLI/pxNGKPfdwHZQMASppOz6DeNKw01cg8HBo4YhU UtEs6muSDXcxpRV1ZAsygvPVQf8KYT0lI/fbmDTo1rZkFSHFPPGLYdf0xZZoG0ZJBeBelO SSsbcCLwmoHsLbwE/sfpPJCTrVmiGOVQgFqFk7jnKpBCy63lpTqb6lnTK20jLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658495070; a=rsa-sha256; cv=none; b=bpZWxkZkfFLDfGEAMw6ELoDgwT7o0/b7yvQUN7ick7z6KRdAa0+9ZYupyYQHOsll0tghu3 n3OLRDHcarKK5yRw7kHqIHI89UyVOoIa6UOaiJxCPDHdhHkihriWGAbPZ/+QQGrHCZvds/ ob0WirqEvh6eRC8wVRa69Zz0aUFX+Qe8vTf+TCoHjj9PJ59e0dUpzkGT4rv/MhMpeDHYHk nGg9/e8iaBtVYWbfeBuOGSSJfKavZiIi8J45ACt5OuxNja5v3K5Lhcz9gDIPuSnzFNUl5n L8bHI7P+jUeLbjBJ/7lhi18T0huh2dbWVnfYuNo1zz4RcAGA6SgfmZ4jw5Nvug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=eeadef8fd52388bb9345df0ef472e0e7feca4afa commit eeadef8fd52388bb9345df0ef472e0e7feca4afa Author: Cy Schubert AuthorDate: 2022-07-14 04:42:06 +0000 Commit: Cy Schubert CommitDate: 2022-07-22 13:04:07 +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 Obtained from: NetBSD hg commit 1019940:4f248823eaff NetBSD PR/56918 (cherry picked from commit a7399ea2dd7810e76dcfd52248764cb8004d49a4) --- 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 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;