Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rufUw-006rIK-Nq for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Apr 2024 21:28:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rufUv-008sfC-K3 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Apr 2024 21:28:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rufUv-008sf4-C9 for pgsql-hackers@lists.postgresql.org; Wed, 10 Apr 2024 21:28:49 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rufUs-000GPa-IW for pgsql-hackers@postgresql.org; Wed, 10 Apr 2024 21:28:48 +0000 Received: from [172.19.157.206] (unknown [212.174.35.38]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4VFGCx0lwLzyWq; Thu, 11 Apr 2024 00:28:44 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1712784525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3kjzFMazsR5Gw27br2t0B606jZjHX0Y9JWLHU/ZEA34=; b=BL1N4jN85y3+S+kh35/C0XLGxfFYxoZbd/s4RfCaQNgSCCYoNb+oCjW0Ubphui/BnztKN6 lxuiw/RqY07Na62tTzObs/QLYH1RkxWKi8KaGhpyrP6CGzc1mMnHN2BYSZROrEG/wYzcdu ybjx/J1djeohTucJideIxibs6b/UAQk= ARC-Seal: i=1; s=meesny; d=iki.fi; t=1712784525; a=rsa-sha256; cv=none; b=KbjTnpBLFD09LennS0FZ3ombg2b8sA7BkaN72GEnWYrekhQE+zg5C9a7bZ8Lg/ZY3EtCxp a/ChEPKpGTVAZRL8He4aOHTWRSSwuCME1gUjzZMtQt3PeIJ2vHrZ3KaYPrtI4QiXihJJJV htXbrrkIjGKA9ZeILdbP+erHUVkfIk8= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1712784525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3kjzFMazsR5Gw27br2t0B606jZjHX0Y9JWLHU/ZEA34=; b=kNOyztNEeyOD4yeV9E/ReubHO4CNqZKulPXHf3QdlTWYwzVw5u3AgrC8YqiOuUGqsQoYRF ipZuzSYuxUi5YAoe3XCbYqONRkG4jD5tm8hbbBHs54pYsQ3wYpsn5isLyDMeAMYkPfukD7 n8D9szYWjMjsWl86hm4ndWPvVGV7248= Message-ID: <02c62e7e-df6b-4b50-8b9e-cdcb3b45c74e@iki.fi> Date: Thu, 11 Apr 2024 00:28:43 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix possible dereference null pointer (src/backend/replication/logical/reorderbuffer.c) Content-Language: en-US To: Ranier Vilela , Pg Hackers References: From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/04/2024 21:07, Ranier Vilela wrote: > Hi, > > Per Coverity. > > The function ReorderBufferTXNByXid, > can return NULL when the parameter *create* is false. > > In the functions ReorderBufferSetBaseSnapshot > and ReorderBufferXidHasBaseSnapshot, > the second call to ReorderBufferTXNByXid, > pass false to *create* argument. > > In the function ReorderBufferSetBaseSnapshot, > fixed passing true as argument to always return > a valid ReorderBufferTXN pointer. > > In the function ReorderBufferXidHasBaseSnapshot, > fixed by checking if the pointer is NULL. If it's a "known subxid", the top-level XID should already have its ReorderBufferTXN entry, so ReorderBufferTXN() should never return NULL. It's not surprising if Coverity doesn't understand that, but setting the 'create' flag doesn't seem like the right fix. If we add "Assert(txn != NULL)", does that silence it? -- Heikki Linnakangas Neon (https://neon.tech)