From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Zhihong Yu <zyu(at)yugabyte(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: remove redundant memset() call |
Date: | 2022-10-13 19:15:13 |
Message-ID: | Y0hjwacUauTMADIL@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Oct 13, 2022 at 12:12:35PM -0700, Zhihong Yu wrote:
> On Thu, Oct 13, 2022 at 12:10 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
> On Thu, Oct 13, 2022 at 10:55:08AM -0700, Zhihong Yu wrote:
> > Hi,
> > I was looking at combo_init in contrib/pgcrypto/px.c .
> >
> > There is a memset() call following palloc0() - the call is redundant.
> >
> > Please see the patch for the proposed change.
> >
> > Thanks
>
> > diff --git a/contrib/pgcrypto/px.c b/contrib/pgcrypto/px.c
> > index 3b098c6151..d35ccca777 100644
> > --- a/contrib/pgcrypto/px.c
> > +++ b/contrib/pgcrypto/px.c
> > @@ -203,7 +203,6 @@ combo_init(PX_Combo *cx, const uint8 *key, unsigned
> klen,
> > if (klen > ks)
> > klen = ks;
> > keybuf = palloc0(ks);
> > - memset(keybuf, 0, ks);
> > memcpy(keybuf, key, klen);
> >
> > err = px_cipher_init(c, keybuf, klen, ivbuf);
>
> Uh, the memset() is ks length but the memcpy() is klen, and the above
> test allows ks to be larger than klen.
>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
> EDB https://enterprisedb.com
>
> Indecision is a decision. Inaction is an action. Mark Batterson
>
>
> Hi,
> the memory has been zero'ed out by palloc0().
>
> memcpy is not relevant w.r.t. resetting memory.
Ah, good point.
--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
Indecision is a decision. Inaction is an action. Mark Batterson
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2022-10-13 19:18:41 | Re: remove redundant memset() call |
Previous Message | Zhihong Yu | 2022-10-13 19:12:35 | Re: remove redundant memset() call |