From owner-dev-commits-src-branches@freebsd.org Sat Jan 30 16:10:33 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7C39C4F18A1; Sat, 30 Jan 2021 16:10:33 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [IPv6:2a01:4f8:c2c:26d8::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DSfLx1lW0z4kG3; Sat, 30 Jan 2021 16:10:32 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [IPv6:2a03:3100:c:13:0:0:0:5]) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id 10UGAKF3073524 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 30 Jan 2021 16:10:23 GMT (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: jilles@FreeBSD.org Received: from [10.58.0.10] (dadvw [10.58.0.10]) by eg.sd.rdtc.ru (8.16.1/8.16.1) with ESMTPS id 10UGAEWX090926 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sat, 30 Jan 2021 23:10:14 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: git: 3708b615c354 - stable/12 - sh: Allow more scripts without #! To: Jilles Tjoelker , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org References: <202101301511.10UFBjcd033018@gitrepo.freebsd.org> From: Eugene Grosbein Message-ID: <5cee1fe4-8aa8-0ad7-55ab-125bfbcb7c7f@grosbein.net> Date: Sat, 30 Jan 2021 23:10:09 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <202101301511.10UFBjcd033018@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,LOCAL_FROM, NICE_REPLY_A,SPF_HELO_NONE,T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record * 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) * 2.6 LOCAL_FROM From my domains * -0.0 NICE_REPLY_A Looks like a legit reply (A) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hz.grosbein.net X-Rspamd-Queue-Id: 4DSfLx1lW0z4kG3 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2021 16:10:33 -0000 30.01.2021 22:11, Jilles Tjoelker wrote: [skip] > +static bool > +isbinary(const char *data, size_t len) > +{ > + const char *nul, *p; > + bool hasletter; > + > + nul = memchr(data, '\0', len); > + if (nul == NULL) > + return false; > + /* > + * POSIX says we shall allow execution if the initial part intended > + * to be parsed by the shell consists of characters and does not > + * contain the NUL character. This allows concatenating a shell > + * script (ending with exec or exit) and a binary payload. > + * > + * In order to reject common binary files such as PNG images, check > + * that there is a lowercase letter or expansion before the last > + * newline before the NUL character, in addition to the check for > + * the newline character suggested by POSIX. > + */ > + hasletter = false; > + for (p = data; *p != '\0'; p++) { > + if ((*p >= 'a' && *p <= 'z') || *p == '$' || *p == '`') > + hasletter = true; > + if (hasletter && *p == '\n') > + return false; > + } > + return true; > +} Before last newline or before first newline?