Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41884

With character_set_connection=utf16 a valid SET time_zone='+00:00' is rejected with ER_UNKNOWN_TIME_ZONE because the raw multi-byte sysvar value is passed to my_tz_find() without charset conversion

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.1
    • 10.11, 11.4, 11.8, 12.3, 13.1
    • Character Sets
    • None
    • MariaDB source HEAD `c894d97781b5` (13.2.0-alpha) and the official image
      `mariadb@sha256:dd9b303aed4f4890ed09f766d8ca9ddfd176c0c6f6267feff53b3192ec65a979`
      (`12.3.3-MariaDB-ubu2404`)

    Description

      `Sys_var_tz::do_check()` validates the new `time_zone` value by calling
      `val_str()` on the item and passing the returned bytes to `my_tz_find()`. When the
      connection character set is a multi-byte non-ASCII set (utf16), the literal written in
      the statement is converted to utf16 bytes, but the returned buffer is a plain
      `latin1`/byte buffer that is not converted back to the system character set before
      `my_tz_find()` performs its offset parsing and hash lookup. Valid values such as
      `'+00:00'` therefore never match and the assignment fails with
      `ER_UNKNOWN_TIME_ZONE` (`ERROR 1298`).

      The interesting part is that the original finding's gate was wrong: `SET NAMES utf16` is
      itself rejected (`ERROR 1231` for `character_set_client`), but
      `SET character_set_connection=utf16` alone is accepted and is sufficient to reproduce the
      `time_zone` failure.

        1. Steps to reproduce (product observation)

      ```sql
      – control
      SET time_zone='+00:00'; – OK, @@session.time_zone = '+00:00'

      – the gate that does NOT work (documented for completeness)
      SET NAMES utf16; – ERROR 1231: Variable 'character_set_client' can't be set to the value of 'utf16'

      – actual reproduction
      SET character_set_connection=utf16;
      SET time_zone='+00:00'; – ERROR 1298 (HY000): Unknown or incorrect time zone: '+00:00'
      ```

      Observed: the control succeeds, `SET NAMES utf16` fails as above, and with
      `character_set_connection=utf16` a valid `time_zone` value is rejected. Machine
      evidence: `mariadb_reproduction_results/dsh_mdsh03_20261023_run2/result.json`,
      SHA-256 `9b8f1710f7bdb39e431cc427c21c6b65a3bb9f3d4ead2720aee96c03a7d35023`.

        1. Expected result

      `SET time_zone='+00:00'` should be accepted regardless of
      `character_set_connection`: the sysvar check should convert the value to the system
      character set (or compare it at the byte level after a well-defined conversion) before
      calling `my_tz_find()`. If a given connection character set is unsupported for this
      sysvar, the error should say so instead of reporting an unknown time zone.

      Attachments

        Activity

          People

            raghunandan.bhat Raghunandan Bhat
            csfuzz csfuzz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Remaining Estimate - 2d
                2d
                Logged:
                Time Spent - Not Specified
                Not Specified

                Git Integration

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