[ODBC-374] SQL_C_FLOAT should be mapped to SQLREAL, and not to SQLFLOAT Created: 2022-11-18  Updated: 2023-01-24  Resolved: 2022-11-18

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: None
Fix Version/s: 3.2.0, 3.1.18

Type: Bug Priority: Major
Reporter: Lawrin Novitsky Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MXS-2709 ETL / Data Migration Service Closed

 Description   

https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/c-data-types?view=sql-server-ver16
Also, SQL_FLOAT should be mapped to SQL_C_DOUBLE, and not SQL_C_FLOAT.
In particular, this can cause.
SQLFLOAT has size 8 bytes - basically it's defined as double, and SQLREAL has size 4 bytes - it is float. In most cases this cause no problem, but can crash application if a rowset(array of rows) is fetched using column-wise binding, and one of fields is fetched to SQL_C_FLOAT buffer. In this case, because of the wrong assumed single field buffer size, connector calculates wrong address to write values from following rows values, and eventually can write past boundary of the allocated array. Correct mapping fixes that issue



 Comments   
Comment by Lawrin Novitsky [ 2022-11-18 ]

The fix and the testcase have been pushed

Generated at Thu Feb 08 03:28:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.