From patchwork Thu Feb 1 07:51:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13540761 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63BB9158D66 for ; Thu, 1 Feb 2024 07:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706773923; cv=none; b=K1kEAQtPGqpre+8IMQo79HT4wA27/FCaf16UeHgplKWcOoFIECphUt7t8dNdc1N31/fuUatL50hXy4WoqLmOAA6/4luZLAI2bcHWWICe7aVnvrkHbgsOTcWy9VkzGAD7nZ8q0y5d+/2ZLwxp/2h1Sl0GoU1nciJBQILlOj4jKsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706773923; c=relaxed/simple; bh=9lhm9BrmUSzT/FRqdJA0OMgkj4DdK2bvq5Txy+TzcLY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j+iraWdUMfZU1BZslBxOtAr9hH3pwtrQmShTvH0p38e2ZyfW1V4bp4s5ltAVI2xyBMTHZ1PnTDMGw8RkvWuj0WnrqcXMRHRUPpvTdS8U3plWFGa78EsOnJnYTSe/7BeZUNkBzR1+3yFa4+pzozDWn2XCsBsi2czhtz2iQXAcTWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=YxU+u5r9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=dt8i4gDl; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="YxU+u5r9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dt8i4gDl" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.west.internal (Postfix) with ESMTP id 17DEC1C00069; Thu, 1 Feb 2024 02:52:00 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 01 Feb 2024 02:52:01 -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:subject :subject:to:to; s=fm3; t=1706773920; x=1706860320; bh=zy7fp1TsAn wdqDSCYTVtkx4q1A96ArZxxyywa6k8ILQ=; b=YxU+u5r9VU6oxQ1E1LRZCOFYIF jjI7m2Yc1BnsKUGNyHS0Pf4xQ56rgvmTEs7VfZ/7zNxGgyPJcywSAxUJ9MlDbiEM hs+nHKhX5MbefiR5T1K4M3U9MFtcDvZ6Oiu2lgSUpEhdKNrwgDJU42WrnNg5Qenr TCTjMG81yFLCEQJAStwnHw7mdS+nH9BYMfRvTP2UuaaAgRg9trgF10zYUsiGTgKn I6v74XIl1a9Uh/14+OKUi6jreV3oFJbL7vrQJPFE0h/kU2jrDnwx5g3vVF/bnIX6 8nOFqLDZHFOzyY7NklagtgPfjX1quckar9xLF/Y75CacSxS+SFWjIpEXQcRw== 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:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1706773920; x=1706860320; bh=zy7fp1TsAnwdqDSCYTVtkx4q1A96 ArZxxyywa6k8ILQ=; b=dt8i4gDlaWJr7J5GLQSiHdOyDCLdzyD5scGfg/5lLYsA DfpzsSSuzmwBlBagVQijHaw8Azh61xdA/YrvHgabc7ARBXC3skUp0db1WFEXXOum iNKSGDeXBIQ6QizAG6X2WodK0UgR2IcjFRRXI7HUrdegOxV+9RiftxNxpRTH6s7H OKOa82Q+3UuglcZhd2eEYjyD6MBTJ6jpLMzssXjhLpCENXYVItJgj7UPWiIJxT/o NDY2opu1ylw/C/8koq5qi82I6KWm4nbrJ1wHP255vYU5Lnrd5malfMAc2l3PLiIc v4cQXCSU6bIM7ALSY+eUvO7YfKxeqPPBv8o34X/D5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedutddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrght rhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtth gvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleff teenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpsh esphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Feb 2024 02:51:59 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 7475996a (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 1 Feb 2024 07:48:36 +0000 (UTC) Date: Thu, 1 Feb 2024 08:51:56 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Junio C Hamano , Toon Claes , Kristoffer Haugsbakk Subject: [PATCH v2 1/5] reftable/reader: be more careful about errors in indexed seeks Message-ID: 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: When doing an indexed seek we first need to do a linear seek in order to find the index block for our wanted key. We do not check the returned error of the linear seek though. This is likely not an issue because the next call to `table_iter_next()` would return error, too. But it very much is a code smell when an error variable is being assigned to without actually checking it. Safeguard the code by checking for errors. Signed-off-by: Patrick Steinhardt --- reftable/reader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reftable/reader.c b/reftable/reader.c index 64dc366fb1..278f727a3d 100644 --- a/reftable/reader.c +++ b/reftable/reader.c @@ -509,6 +509,9 @@ static int reader_seek_indexed(struct reftable_reader *r, goto done; err = reader_seek_linear(&index_iter, &want_index); + if (err < 0) + goto done; + while (1) { err = table_iter_next(&index_iter, &index_result); table_iter_block_done(&index_iter);