Issue Details (XML | Word | Printable)

Key: ODBC-160
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Alexander Potapchenko
Reporter: Jojakim Stahl
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ODBC Driver

Bound Input Parameter of type SQL_C_WCHAR containing surrogate pairs may be truncated

Created: 06/Feb/13 11:59 AM   Updated: 18/Jul/17 11:05 AM
Component/s: None
Affects Version/s: 2.0.1, 2.0.2
Fix Version/s: 2.0.5, 2.1 Beta

File Attachments: 1. Text File bug-160-new.patch (3 kB)



 Description  « Hide
Do the following (pseudo-code)

create table test (
strfield varchar(30) character set UTF8
)

SQLDriverConnect( ... CHARSET=UTF8 ...)

SQLPrepareW(hStmt, "insert into test values (?)", SQL_NTS)

SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 30, 0, str_field, sizeof(str_field), &str_field_len);

with str_field containing min 30 chars, and min. one of them beeing a surrogate pairs, means a string conating more than 30 wchar_t entities.
The string can be converted to the UTF8 field without any loss, because FB allows up to 30*4 bytes for the field. However, the driver does assume, that one wchar_t unit results in one char (covering up to 4 bytes in UTF8). The input value will be truncated to 30 wchar_t entities instead of 30 charachters.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jojakim Stahl added a comment - 06/Feb/13 02:40 PM
This patch solves the issue.
I tried to solve it with as minimal as possible code changes (at least I hope so).
The downside is one additional scan of the input string.
Otherwise I had to rework all the WcsToMbs function signatures in order to in- and output detailed string length and character count information to/from these functions.

Jojakim Stahl added a comment - 28/Feb/13 04:38 PM
a second patch to apply after the first one.
tests revealed a bug in the first patch.

Jojakim Stahl added a comment - 31/Oct/14 01:46 PM
Summary patch based on current cvs-head
The patch invalidates all previously puplished patches.

Jojakim Stahl added a comment - 31/Oct/14 03:40 PM
Sorry, the summary patch contained changes for each line due to oel-style problem.
Please use only the "bug-160-new.patch".
The other attachments can be deleted. (I do not have permissions to do so)

Alexander Potapchenko added a comment - 01/Nov/14 11:57 AM
Thanks, this patch will be applied for next release after testing.

Alexander Potapchenko added a comment - 02/Jan/17 01:20 PM
Fixed in CVS