public inbox for [email protected]  
help / color / mirror / Atom feed
From: Zhihong Yu <[email protected]>
To: Tom Lane <[email protected]>
Cc: Noah Misch <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: null iv parameter passed to combo_init()
Date: Sun, 9 Jan 2022 04:37:32 -0800
Message-ID: <CALNJ-vTuaO+6hM4wY2aE0V7WdB56bwTXDp50Bn2U1ggmonVGbA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CALNJ-vSBb2Ees=KB0frYBh7foK-QNZMbK7Vz66bUJa09D+CHAw@mail.gmail.com>
	<[email protected]>
	<CALNJ-vTh9BXARHg3iaCAzr97Fws2W5aR6nRPJfT4u3VdKDzRTQ@mail.gmail.com>
	<[email protected]>
	<[email protected]>

On Sat, Jan 8, 2022 at 11:32 PM Tom Lane <[email protected]> wrote:

> Noah Misch <[email protected]> writes:
> > On further thought, I would write it this way:
>
> > -             else
> > +             else if (ivlen != 0)
> >                       memcpy(ivbuf, iv, ivlen);
>
> FWIW, I liked the "ivlen > 0" formulation better.  They should be
> equivalent, because ivlen is unsigned, but it just seems like "> 0"
> is more natural.
>
>                         regards, tom lane
>

Patch v4 is attached.

Cheers


Attachments:

  [application/octet-stream] 0004-memcpy-null.patch (2.2K, ../CALNJ-vTuaO+6hM4wY2aE0V7WdB56bwTXDp50Bn2U1ggmonVGbA@mail.gmail.com/3-0004-memcpy-null.patch)
  download | inline diff:
diff --git a/contrib/pgcrypto/px.c b/contrib/pgcrypto/px.c
index 4205e9c3ef..2099ce2a7a 100644
--- a/contrib/pgcrypto/px.c
+++ b/contrib/pgcrypto/px.c
@@ -200,7 +200,7 @@ combo_init(PX_Combo *cx, const uint8 *key, unsigned klen,
 		ivbuf = palloc0(ivs);
 		if (ivlen > ivs)
 			memcpy(ivbuf, iv, ivs);
-		else
+		else if (ivlen > 0)
 			memcpy(ivbuf, iv, ivlen);
 	}
 
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index de787c3d37..eca1e5dd0e 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -294,7 +294,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
 	 * sub-XIDs and all of the XIDs for which we're adjusting clog should be
 	 * on the same page.  Check those conditions, too.
 	 */
-	if (all_xact_same_page && xid == MyProc->xid &&
+	if (subxids != NULL && all_xact_same_page && xid == MyProc->xid &&
 		nsubxids <= THRESHOLD_SUBTRANS_CLOG_OPT &&
 		nsubxids == MyProc->subxidStatus.count &&
 		memcmp(subxids, MyProc->subxids.xids,
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index c9516e03fa..3d5ca89d42 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -5329,7 +5329,7 @@ SerializeTransactionState(Size maxsize, char *start_address)
 	 * of our own, we can just pass along the information that was passed to
 	 * us.
 	 */
-	if (nParallelCurrentXids > 0)
+	if (nParallelCurrentXids > 0 && ParallelCurrentXids != NULL)
 	{
 		result->nParallelCurrentXids = nParallelCurrentXids;
 		memcpy(&result->parallelCurrentXids[0], ParallelCurrentXids,
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index e5cf1bde13..ae10c55711 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -1182,7 +1182,10 @@ DefineIndex(Oid relationId,
 			pgstat_progress_update_param(PROGRESS_CREATEIDX_PARTITIONS_TOTAL,
 										 nparts);
 
-			memcpy(part_oids, partdesc->oids, sizeof(Oid) * nparts);
+			if (partdesc->oids != NULL)
+			{
+				memcpy(part_oids, partdesc->oids, sizeof(Oid) * nparts);
+			}
 
 			parentDesc = RelationGetDescr(rel);
 			opfamOids = palloc(sizeof(Oid) * numberOfKeyAttributes);


view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: null iv parameter passed to combo_init()
  In-Reply-To: <CALNJ-vTuaO+6hM4wY2aE0V7WdB56bwTXDp50Bn2U1ggmonVGbA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox