From owner-svn-src-head@freebsd.org Mon Sep 9 15:28:23 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45394D55EA; Mon, 9 Sep 2019 15:28:23 +0000 (UTC) (envelope-from bapt@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46RsWC0kC9z46pX; Mon, 9 Sep 2019 15:28:23 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F1057FA83; Mon, 9 Sep 2019 15:28:22 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x89FSM3N004965; Mon, 9 Sep 2019 15:28:22 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x89FSMd6004964; Mon, 9 Sep 2019 15:28:22 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201909091528.x89FSMd6004964@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 9 Sep 2019 15:28:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352068 - head/usr.bin/m4 X-SVN-Group: head X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: head/usr.bin/m4 X-SVN-Commit-Revision: 352068 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Sep 2019 15:28:23 -0000 Author: bapt Date: Mon Sep 9 15:28:22 2019 New Revision: 352068 URL: https://svnweb.freebsd.org/changeset/base/352068 Log: m4: import patch from OpenBSD by espie@ ifelse is special, fix argv parsing to avoid segfault problem noticed by Matthew Green (netbsd), slightly different fix so that argc counting makes more sense. we might want to warn on wrong number of parameters later, but this is somewhat inconsistent depending on the builtin right now. okay millert@ Obtained from: OpenBSD Modified: head/usr.bin/m4/eval.c Modified: head/usr.bin/m4/eval.c ============================================================================== --- head/usr.bin/m4/eval.c Mon Sep 9 15:24:48 2019 (r352067) +++ head/usr.bin/m4/eval.c Mon Sep 9 15:28:22 2019 (r352068) @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.75 2017/06/15 13:48:42 bcallah Exp $ */ +/* $OpenBSD: eval.c,v 1.76 2017/10/23 15:21:19 espie Exp $ */ /* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */ /*- @@ -201,8 +201,7 @@ expand_builtin(const char *argv[], int argc, int td) } case IFELTYPE: - if (argc > 4) - doifelse(argv, argc); + doifelse(argv, argc); break; case IFDFTYPE: @@ -695,17 +694,17 @@ dotrace(const char *argv[], int argc, int on) static void doifelse(const char *argv[], int argc) { - cycle { - if (STREQ(argv[2], argv[3])) + while (argc > 4) { + if (STREQ(argv[2], argv[3])) { pbstr(argv[4]); - else if (argc == 6) + break; + } else if (argc == 6) { pbstr(argv[5]); - else if (argc > 6) { + break; + } else { argv += 3; argc -= 3; - continue; } - break; } }