From patchwork Mon Dec 11 09:07:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13486859 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="Go7MMFve"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bEDBbi0t" Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08014DF for ; Mon, 11 Dec 2023 01:07:38 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 2288F320261E; Mon, 11 Dec 2023 04:07:37 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 11 Dec 2023 04:07:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1702285656; x=1702372056; bh=3K FSWMNUw2QtyMjQHIzOfM74ETwtxfNqimrqZipOlhU=; b=Go7MMFveDvoHzPI+DE zw8oT5l5+HEA5xxeWGjDIy2PHRDI2P6Z03JpNjVNeU5I/ndC+EHioWyjsPESi+a3 JEQBaqdTKiCD4IYx5huq2gcexw18nmS/WjfQU+tUgAOp75jLSyw+GAWMM4yjP6oJ kSLLI0tnSNJdsNkS5y0Ut4PwOo+/2eA407sQUBuCZscBYWSruEp4aDjiPKvy4q0I JvdEydi1uqGANL0A4wwdyxPv2kDF6DkwRoOv6mZslH2vqroNOH4jlosZQ/hIB++k qO/Db60Px95ZJYeVm1bcSJen+e5fsKYF958gmT0R/wbp+GviJ5FWuB3LuQtLaNk7 W91g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1702285656; x=1702372056; bh=3KFSWMNUw2Qty MjQHIzOfM74ETwtxfNqimrqZipOlhU=; b=bEDBbi0tNjkw6g2gsahRKquJSbOyt HlwFsTsz5TJIqbJsIOE+fIBub0fQZ4xlIYvLWe6/GuJ5kmavY7MDDP68cCwoZK4y a3pgYCd95WLVPb8mu+AueS/RDPvyPWoG2yQTaAmGBXo4a9FgbDhXbIDdT0DDA1bd 3UJEYL9VzTU0jbic5ms0BeOgyFA/U9T9UHSe72dZ4SParTe13SdIWloXQk5eEb4O 1OAxSl0Xl/lLx1RSSeS9qpqE5FsTNrHA0bBpp8Q0CTuDLYy4UHRHeJd0p8T3RFlP LZc4jZ9cQrLNF3aMVZF1cdG7yasgULJ6jpkcuNfXjYlT4voRA29Gf5kOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeluddguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrght rhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtth gvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleff teenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehpsh esphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Dec 2023 04:07:35 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id b88dbf0d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 11 Dec 2023 09:05:59 +0000 (UTC) Date: Mon, 11 Dec 2023 10:07:34 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Jonathan Nieder , Taylor Blau , Eric Sunshine Subject: [PATCH v3 02/11] reftable: handle interrupted reads Message-ID: <3e8e63ece52c507296b012be6632dbed568ff97d.1702285387.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: There are calls to pread(3P) and read(3P) where we don't properly handle interrupts. Convert them to use `pread_in_full()` and `read_in_full()`, respectively. Signed-off-by: Patrick Steinhardt --- reftable/blocksource.c | 2 +- reftable/stack.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reftable/blocksource.c b/reftable/blocksource.c index 8331b34e82..a1ea304429 100644 --- a/reftable/blocksource.c +++ b/reftable/blocksource.c @@ -109,7 +109,7 @@ static int file_read_block(void *v, struct reftable_block *dest, uint64_t off, struct file_block_source *b = v; assert(off + size <= b->size); dest->data = reftable_malloc(size); - if (pread(b->fd, dest->data, size, off) != size) + if (pread_in_full(b->fd, dest->data, size, off) != size) return -1; dest->len = size; return size; diff --git a/reftable/stack.c b/reftable/stack.c index ddbdf1b9c8..ed108a929b 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -92,7 +92,7 @@ static int fd_read_lines(int fd, char ***namesp) } buf = reftable_malloc(size + 1); - if (read(fd, buf, size) != size) { + if (read_in_full(fd, buf, size) != size) { err = REFTABLE_IO_ERROR; goto done; }