Re: ARRNELEMS Out-of-bounds possible errors

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Nikita Malakhov <hukutoc(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ARRNELEMS Out-of-bounds possible errors
Date: 2022-12-22 22:20:26
Message-ID: CAEudQArkLAqnX0QiJiqtd5uHwaeUwcm8TVqSMRvNzMwqeKrDrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em qui., 22 de dez. de 2022 às 15:45, Nikita Malakhov <hukutoc(at)gmail(dot)com>
escreveu:

> Hi,
>
> Actually, there would be much more sources affected, like
> nbytes += subbytes[outer_nelems];
> subnitems[outer_nelems] = ArrayGetNItems(this_ndims,
> ARR_DIMS(array));
> nitems += subnitems[outer_nelems];
> havenulls |= ARR_HASNULL(array);
> outer_nelems++;
> }
>
> Maybe it is better for most calls like this to keep old behavior, by
> passing a flag
> that says which behavior is expected by caller?
>
I agreed that it is better to keep old behavior.
Even the value 0 is problematic, with calls like this:

nel = ARRNELEMS(ent);
memcpy(ptr, ARRPTR(ent), nel * sizeof(int32));

regards,
Ranier Vilela

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-12-22 23:47:24 Re: Allow WindowFuncs prosupport function to use more optimal WindowClause options
Previous Message Thomas Munro 2022-12-22 22:06:42 Re: Array initialisation notation in syscache.c