Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Daniel Gustafsson
> On 17 Feb 2022, at 16:05, Tom Lane wrote: > > Daniel Gustafsson writes: >> Question remains though, should src/interfaces/ecpg/test/sql/sqlda.pgc really >> be using WIN32 and not _WIN32, or doesn't it matter? (or does it only matter >> for consistency?) WIN32 and _WIN32 aren't very informativ

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Tom Lane
Daniel Gustafsson writes: > Question remains though, should src/interfaces/ecpg/test/sql/sqlda.pgc really > be using WIN32 and not _WIN32, or doesn't it matter? (or does it only matter > for consistency?) WIN32 and _WIN32 aren't very informative searchterms to use > for finding more information.

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Ranier Vilela
Em qui., 17 de fev. de 2022 às 10:18, Daniel Gustafsson escreveu: > > On 17 Feb 2022, at 13:59, Ranier Vilela wrote: > > > > Em qui., 17 de fev. de 2022 às 09:52, Daniel Gustafsson > escreveu: > > > On 17 Feb 2022, at 13:19, Ranier Vilela ranier...@gmail.com>> wrote: >

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Daniel Gustafsson
> On 17 Feb 2022, at 13:59, Ranier Vilela wrote: > > Em qui., 17 de fev. de 2022 às 09:52, Daniel Gustafsson > escreveu: > > On 17 Feb 2022, at 13:19, Ranier Vilela > > wrote: > > > 1. One #ifdef with a mistake, the correct is _WIN32 and not

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Ranier Vilela
Em qui., 17 de fev. de 2022 às 09:52, Daniel Gustafsson escreveu: > > On 17 Feb 2022, at 13:19, Ranier Vilela wrote: > > > 1. One #ifdef with a mistake, the correct is _WIN32 and not WIN32. > > Can you elaborate on this, we are using WIN32 pretty extensively in the > code: > > $ git grep "if[n]

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Daniel Gustafsson
> On 17 Feb 2022, at 13:19, Ranier Vilela wrote: > 1. One #ifdef with a mistake, the correct is _WIN32 and not WIN32. Can you elaborate on this, we are using WIN32 pretty extensively in the code: $ git grep "if[n]\{0,1\}def WIN32$"|wc -l 511 $ git grep "if[n]\{0,1\}def _WIN32$"|wc -l

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Ranier Vilela
Sorry for the break post... Em qui., 17 de fev. de 2022 às 05:25, Kyotaro Horiguchi < horikyota@gmail.com> escreveu: > At Thu, 17 Feb 2022 15:50:09 +0800, Julien Rouhaud > wrote in > > On Thu, Feb 17, 2022 at 03:51:26PM +0900, Kyotaro Horiguchi wrote: > > > So, the function doesn't return 63

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Ranier Vilela
Em qui., 17 de fev. de 2022 às 05:25, Kyotaro Horiguchi < horikyota@gmail.com> escreveu: > At Thu, 17 Feb 2022 15:50:09 +0800, Julien Rouhaud > wrote in > > On Thu, Feb 17, 2022 at 03:51:26PM +0900, Kyotaro Horiguchi wrote: > > > So, the function doesn't return 63 for all registered names and

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Julien Rouhaud
On Thu, Feb 17, 2022 at 05:24:58PM +0900, Kyotaro Horiguchi wrote: > At Thu, 17 Feb 2022 15:50:09 +0800, Julien Rouhaud wrote > in > > On Thu, Feb 17, 2022 at 03:51:26PM +0900, Kyotaro Horiguchi wrote: > > > So, the function doesn't return 63 for all registered names and wrong > > > names. > > >

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-17 Thread Kyotaro Horiguchi
At Thu, 17 Feb 2022 15:50:09 +0800, Julien Rouhaud wrote in > On Thu, Feb 17, 2022 at 03:51:26PM +0900, Kyotaro Horiguchi wrote: > > So, the function doesn't return 63 for all registered names and wrong > > names. > > > > So other possibilities I can think of are.. > > - Someone had broken pg_e

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-16 Thread Julien Rouhaud
On Thu, Feb 17, 2022 at 03:51:26PM +0900, Kyotaro Horiguchi wrote: > At Thu, 17 Feb 2022 14:58:38 +0900 (JST), Kyotaro Horiguchi > wrote in > > (Sorry for the broken mail...) > > > > > > > Ok, if -1 is wrong, what should the value of return if > > > somebody calling this function like: > > > pg_

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-16 Thread Kyotaro Horiguchi
At Thu, 17 Feb 2022 15:51:26 +0900 (JST), Kyotaro Horiguchi wrote in > - Cosmic ray hit, or ill memory cell. 63 (0x3f) cannot be less than 42(0x2a) by one-bit flip. So the possibility of cosmic ray would be quite low. regards. -- Kyotaro Horiguchi NTT Open Source Software Center

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-16 Thread Kyotaro Horiguchi
At Thu, 17 Feb 2022 14:58:38 +0900 (JST), Kyotaro Horiguchi wrote in > (Sorry for the broken mail...) > > At Wed, 16 Feb 2022 09:29:20 -0300, Ranier Vilela wrote > in > > > The patch: > > > pg_encoding_max_length(int encoding) > > > { > > > - Assert(PG_VALID_ENCODING(encoding)); > >

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-16 Thread Kyotaro Horiguchi
(Sorry for the broken mail...) At Wed, 16 Feb 2022 09:29:20 -0300, Ranier Vilela wrote in > > > ] > > > 633retval = pg_verify_mbstr_len(src_encoding, src_str, len, > > false); > > > 634 > > > > > > Trivial patch attached. > > > > Mmm? If the assert doesn't work, there should be inconcsi

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-16 Thread Kyotaro Horiguchi
At Wed, 16 Feb 2022 09:29:20 -0300, Ranier Vilela wrote in > > > ] > > > 633retval = pg_verify_mbstr_len(src_encoding, src_str, len, > > false); > > > 634 > > > > > > Trivial patch attached. > > > > Mmm? If the assert doesn't work, there should be inconcsistency > > between pg_enc and pg

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-16 Thread Ranier Vilela
Em qua., 16 de fev. de 2022 às 00:12, Kyotaro Horiguchi < horikyota@gmail.com> escreveu: > At Tue, 15 Feb 2022 09:17:34 -0300, Ranier Vilela > wrote in > > Per Coverity. > > Thanks for the source:) > > > Like the function pg_encoding_max_length_sql > > (src/backend/utils/mb/mbutils.c) > > Onl

Re: [PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-15 Thread Kyotaro Horiguchi
At Tue, 15 Feb 2022 09:17:34 -0300, Ranier Vilela wrote in > Per Coverity. Thanks for the source:) > Like the function pg_encoding_max_length_sql > (src/backend/utils/mb/mbutils.c) > Only assertion is insufficient to avoid accessing array out-of-bounds. > > This bug is live according Coverity

[PATCH] Fix out-of-bouds access (src/common/wchar.c)

2022-02-15 Thread Ranier Vilela
Hi, Per Coverity. Like the function pg_encoding_max_length_sql (src/backend/utils/mb/mbutils.c) Only assertion is insufficient to avoid accessing array out-of-bounds. This bug is live according Coverity at function: pg_verify_mbstr_len (src/backend/utils/mb/mbutils.c) CID 1469870 (#1 of 1): Out-