From patchwork Tue Dec 13 22:17:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13072491 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FD03C4332F for ; Tue, 13 Dec 2022 22:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234910AbiLMWRi (ORCPT ); Tue, 13 Dec 2022 17:17:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbiLMWRh (ORCPT ); Tue, 13 Dec 2022 17:17:37 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3CD1DDE4 for ; Tue, 13 Dec 2022 14:17:36 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 1EF5AEE2 for ; Tue, 13 Dec 2022 23:17:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1670969853; bh=/XHN6lnE9/k9i04p5Kh/g/2YZNYqjUK4jM2Gu9hN0Xc=; h=Date:From:To:Subject:From; b=WxLPs93R9Y5xHq7LDm5cMFmIHNlOwYZIFYmIOHe51RceBoDmwAhK3anVt3xyNX/fW JZkdPhxe4Ib6eHnWvTsAYGKKdbafbwI4258NnHMKxjzyrLNADHiqgW49pL1CGdEDvO 4H4PQlIiGKPCY937J3P99VoQdHjda1HWw8/CGlrF+o6q8zgrRphZMU8fZXyT5X6APR xX47W6fKAV4NEdX9U07F9iSExB82aC1nZ6VUtzORCZnKSdtJQNlllzWG0AbEmxNUZU BEsxWfAx2cEP8JxvsnC0cfkzbZoN8yIkxQFJSFMclpzdxnBVRlFkuzt1s5fRZi9GbI k0Uj5zYas9vtw== Date: Tue, 13 Dec 2022 23:17:32 +0100 From: =?utf-8?b?0L3QsNCx?= To: dash@vger.kernel.org Subject: [PATCH] input: preadfd: read standard input byte-wise Message-ID: <20221213221732.6mvv22u7ktdozrbx@tarta.nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20220429 Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org POSIX Issue 7, XCU, sh, STDIN says: When the shell is using standard input and it invokes a command that also uses standard input, the shell shall ensure that the standard input file pointer points directly after the command it has read when the command begins execution. It shall not read ahead in such a manner that any characters intended to be read by the invoked command are consumed by the shell (whether interpreted by the shell or not) or that characters that are not read by the invoked command are not seen by the shell. I.e. sh <fd, buf, IBUFSIZ - 1); + nr = read(parsefile->fd, buf, parsefile->fd == 0 ? 1 : IBUFSIZ - 1); if (nr < 0) {