babelfish-for-postgresql / babelfish_extensions

Babelfish for PostgreSQL provides the capability for PostgreSQL to work with applications written for Microsoft SQL Server. Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query and procedural language, so you don’t have to switch database drivers or rewrite all of your application queries.
https://babelfishpg.org/
Apache License 2.0
274 stars 93 forks source link

Fix crash in datumCopy during copyParamList() when pgaudit is installed #2871

Closed tanscorpio7 closed 1 month ago

tanscorpio7 commented 1 month ago

Description

Fix crash in datum copy when pgaudit copies the parameters of the internal prep/exec query used to insert rows into TVP. Root cause was incorrect computation of rowCount in TVP, and incorrect count of bind variables (nargs) of internal prep/exec query for TVP since it depends upon rowCount as well.

pgaudit then copies all the bind variables using the total count we provided and ends up accessing an out of bound index of the values array.

Issues Resolved

[BABEL-4983]

Test Scenarios Covered

Locally ran the java script which produces the crash and verified that crash does not happen post fix.

Sign Off

Signed-off-by: Tanzeel Khan tzlkhan@amazon.com

Check List

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 10492663685

Details


Totals Coverage Status
Change from base Build 10466946356: 0.0%
Covered Lines: 44448
Relevant Lines: 60016

💛 - Coveralls
jsudrik commented 1 month ago

Fix crash in datum copy when pgaudit copies the parameters of the internal prep/exec query used to insert rows into TVP. Root cause was incorrect computation of rowCount in TVP, and incorrect count of bind variables (nargs) of internal prep/exec query for TVP since it depends upon rowCount as well.

pgaudit then copies all the bind variables using the total count we provided and ends up accessing an out of bound index of the values array.

Issues Resolved [BABEL-4983]

Signed-off-by: Tanzeel Khan tzlkhan@amazon.com