pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
8+ messages / 2 participants
[nested] [flat]

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9a51d4af12a7add717f7f2e4b82985b3a7a092f4

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a0bff38d133ac95fb56bbd868a128bba95ec46c9

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2c37cb26f8af0aecb1b534585f3a0234f70e69ee

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fcafbaadf7e507708d7257282e1ddcee1cc4c5eb

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/335501fb2b8007000d8c154628065355b5cd4366

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9ecfd8a48adf84ec5603a53a6e1a5add097ab56f

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-22 23:35  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Michael Paquier @ 2024-10-22 23:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

ecpg: Fix out-of-bound read in DecodeDateTime()

It was possible for the code to read out-of-bound data from the
"day_tab" table with some crafted input data.  Let's treat these as
invalid input as the month number is incorrect.

A test is added to test this case with a check on the errno returned by
the decoding routine.  A test close to the new one added in this commit
was testing for a failure, but did not look at the errno generated, so
let's use this commit to also change it, adding a check on the errno
returned by DecodeDateTime().

Like the other test scripts, dt_test should likely be expanded to
include more checks based on the errnos generated in these code paths.
This is left as future work.

This issue exists since 2e6f97560a83, so backpatch all the way down.

Reported-by: Pavel Nekrasov
Author: Bruce Momjian, Pavel Nekrasov
Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
Backpatch-through: 12

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a1e613b81aa05b5e29dcb531016269b103208a7d

Modified Files
--------------
src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
.../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
.../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
.../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
5 files changed, 109 insertions(+), 48 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: ecpg: Fix out-of-bound read in DecodeDateTime()
@ 2024-10-31 14:44  Bruce Momjian <bruce@momjian.us>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 8+ messages in thread

From: Bruce Momjian @ 2024-10-31 14:44 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-committers@lists.postgresql.org


Great, thanks for applying this.  I was traveling so am only now back to
looking at this.

---------------------------------------------------------------------------

On Tue, Oct 22, 2024 at 11:35:51PM +0000, Michael Paquier wrote:
> ecpg: Fix out-of-bound read in DecodeDateTime()
> 
> It was possible for the code to read out-of-bound data from the
> "day_tab" table with some crafted input data.  Let's treat these as
> invalid input as the month number is incorrect.
> 
> A test is added to test this case with a check on the errno returned by
> the decoding routine.  A test close to the new one added in this commit
> was testing for a failure, but did not look at the errno generated, so
> let's use this commit to also change it, adding a check on the errno
> returned by DecodeDateTime().
> 
> Like the other test scripts, dt_test should likely be expanded to
> include more checks based on the errnos generated in these code paths.
> This is left as future work.
> 
> This issue exists since 2e6f97560a83, so backpatch all the way down.
> 
> Reported-by: Pavel Nekrasov
> Author: Bruce Momjian, Pavel Nekrasov
> Discussion: https://postgr.es/m/18614-6bbe00117352309e@postgresql.org
> Backpatch-through: 12
> 
> Branch
> ------
> master
> 
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/a0bff38d133ac95fb56bbd868a128bba95ec46c9
> 
> Modified Files
> --------------
> src/interfaces/ecpg/pgtypeslib/dt_common.c         |  6 +-
> .../ecpg/test/expected/pgtypeslib-dt_test.c        | 76 +++++++++++++++-------
> .../ecpg/test/expected/pgtypeslib-dt_test.stderr   | 42 ++++++------
> .../ecpg/test/expected/pgtypeslib-dt_test.stdout   |  3 +-
> src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc    | 30 +++++++++
> 5 files changed, 109 insertions(+), 48 deletions(-)
> 


-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  When a patient asks the doctor, "Am I going to die?", he means 
  "Am I going to die soon?"





^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2024-10-31 14:44 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>
2024-10-31 14:44 ` Bruce Momjian <bruce@momjian.us>
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>
2024-10-22 23:35 pgsql: ecpg: Fix out-of-bound read in DecodeDateTime() Michael Paquier <michael@paquier.xyz>

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