Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-418

Widechar string data gets truncated if contains NULL character

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.2.1, 3.1.20
    • 3.2.2
    • General
    • win 11 pro, vb6, pc desktop, mariaDB 11.3 64 bit Maria ODBC 32 bit drivers

    Description

      I have been using Mysql 8.0.36 64 bit server and the Mysql 8 ODBC ANSI and UNICODE driver, and my vb6 app is working perfectly. but I installed MariaDB 11.3 64 bit and the 32 bit MariaDB odbc driver (windows 11), and I get errors like cannot locate row for updating, and an encrypted string is not stored properly, seems to be truncated shorter on reading it back from the table.
      Does not matter if MariaDB is configured for UTF8 or not, it is all related to the MariaDB 3.1 ODBC 32 bit driver. I tested that. I also tried the 3.2 experimental driver and get same failures.

      Here is the table creation. I encrypt a string and store it in 'usertable.password' and usertable.priveleges, but string in ''priveliges' is corrupted- changed by the ODBC driver wrongly either when written or read, it comes back truncated too small.

      frmLogon.cnConnector.Execute "DROP TABLE IF EXISTS usertable"
          frmLogon.cnConnector.Execute "CREATE TABLE IF NOT EXISTS usertable" & _
          "(Id INT AUTO_INCREMENT PRIMARY KEY," & _
          "MyName VARCHAR(50) DEFAULT ''," & _
          "Myuser VARCHAR(50) DEFAULT ''," & _
          "password VARCHAR(50) DEFAULT ''," & _
          "Priveliges CHAR (21) DEFAULT '',TS TIMESTAMP," & _
          "UserDate DATETIME DEFAULT CURRENT_TIMESTAMP) ENGINE = INNODB"
      frmLogon.cnConnector.Execute "CREATE INDEX MyuserIndex ON usertable(Myuser)"
      

      All this works perfect with the MySQL ODBC 8 driver, but fails with the MariaDB ODBC 3.1 32 bit driver

      Here is the string function to encrypt a character string

      The string that fails for example is this "A11111111111111111111"

       priv = Encrypt("A11111111111111111111", "1234567890")
      

      Public Function Encrypt(secret As Variant, PassWord As Variant) As Variant
            'The passwords and privileges are encrypted with "1234567890"
           'the connection string is encrypted with "123456789"
           'Win98 had a problem with 1234567890
           
           ' secret = the string you wish to encrypt or decrypt.
           ' PassWord = the password with which to encrypt the string.
            <skipped>   
       
      End Function
      

      When I try to update this 'usertable', using the MariaDB 3.1 32 bit ODBC driver, I get row can not be located for updating. However just by using the Mysql 8 ODBC 32 bit driver on the MariaDB 11.3, it works fine. I also use option = 34 in my connection string.

      This procedure causes the row cannot be located for updating error , and if you notice, the same issue with the encrypting function is likely the issue.

      If Addnew = False Then
             frmLogon.rsusertable.CursorLocation = adUseClient
             SQLQuery = "Select * from usertable where myuser = " & nl & "'" & Trim(Combo1.Text) & "'"
             frmLogon.rsusertable.Open SQLQuery, frmLogon.cnConnector, adOpenDynamic, adLockOptimistic
             'like try to change name field
             'then has to be delete old name and addnew name
             If frmLogon.rsusertable.RecordCount = 0 Then
               Addnew = True
               GoTo AddNewName:
             End If
             frmLogon.rsusertable!MyName = Trim(txtMyName.Text)
             frmLogon.rsusertable!MYUser = Trim(Combo1.Text)
             'encrypt the password string.
             frmLogon.rsusertable!PassWord = Encrypt(Trim(txtPassword.Text), "1234567890")
             priv = ""
             'determine the access group
             If Option1(0).Value = True Then priv = "A"
             If Option1(1).Value = True Then priv = "P"
             If Option1(2).Value = True Then priv = "G"
             If priv = "" Then priv = "A"
             'add up the checkbox options
             xx = 0
             Do Until xx = 20
               priv = priv & Check1(xx).Value
               xx = xx + 1
             Loop
             'encrypt the priv string.
             frmLogon.rsusertable!priveliges = Encrypt(priv, "1234567890")
             frmLogon.rsusertable.Update
          End If  
      

      yes, just verified, if comment out the encrypt function lines in the above code, it executes without an errors

      Attachments

        1. Screenshot 2024-03-19 121046.png
          384 kB
          Scott Downey

        Activity

          People

            Lawrin Lawrin Novitsky
            Scott Scott Downey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.