Re: ARRNELEMS Out-of-bounds possible errors

2022-12-26 Thread Ranier Vilela
Em seg., 26 de dez. de 2022 às 15:45, Nikita Malakhov escreveu: > Hi, > > My bad, I was misleaded by unconditional return in ereturn_domain. > Sorry for the noise. > By no means, the mistake was entirely mine, I apologize to you. regards, Ranier Vilela

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-26 Thread Nikita Malakhov
Hi, My bad, I was misleaded by unconditional return in ereturn_domain. Sorry for the noise. On Sat, Dec 24, 2022 at 7:05 PM Tom Lane wrote: > Nikita Malakhov writes: > > Even with null context it does not turn to ereport, and returns dummy > value > > Read the code. ArrayGetNItems passes

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-24 Thread Tom Lane
Nikita Malakhov writes: > Even with null context it does not turn to ereport, and returns dummy value Read the code. ArrayGetNItems passes NULL for escontext, therefore if there's a problem the ereturn calls in ArrayGetNItemsSafe will throw error, *not* return -1. Not sure how we could

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-24 Thread Nikita Malakhov
Hi, Even with null context it does not turn to ereport, and returns dummy value - #define errsave_domain(context, domain, ...) \ do { \ struct Node *context_ = (context); \ pg_prevent_errno_in_scope(); \ if (errsave_start(context_, domain)) \ __VA_ARGS__, errsave_finish(context_, __FILE__,

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-23 Thread Kyotaro Horiguchi
At Fri, 23 Dec 2022 17:37:55 +0900 (JST), Kyotaro Horiguchi wrote in > At Thu, 22 Dec 2022 12:35:58 -0300, Ranier Vilela wrote > in > > Hi. > > > > Per Coverity. > > > > The commit ccff2d2 > > , > >

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-23 Thread Kyotaro Horiguchi
At Thu, 22 Dec 2022 12:35:58 -0300, Ranier Vilela wrote in > Hi. > > Per Coverity. > > The commit ccff2d2 > , > changed the behavior function ArrayGetNItems, > with the introduction of the function

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-22 Thread Nikita Malakhov
Hi, The most obvious solution I see is to check all calls and for cases like we both mentioned to pass a flag meaning safe or unsafe (for these cases) behavior is expected, like #define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x), false) ... int ArrayGetNItems(int ndim, const int

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-22 Thread Ranier Vilela
Em qui., 22 de dez. de 2022 às 15:45, Nikita Malakhov escreveu: > Hi, > > Actually, there would be much more sources affected, like > nbytes += subbytes[outer_nelems]; > subnitems[outer_nelems] = ArrayGetNItems(this_ndims, >

Re: ARRNELEMS Out-of-bounds possible errors

2022-12-22 Thread Nikita Malakhov
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 |=

ARRNELEMS Out-of-bounds possible errors

2022-12-22 Thread Ranier Vilela
Hi. Per Coverity. The commit ccff2d2 , changed the behavior function ArrayGetNItems, with the introduction of the function ArrayGetNItemsSafe. Now ArrayGetNItems may return -1, according to the comment. "