You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kudu.apache.org by "Gabriella Lotz (Jira)" <ji...@apache.org> on 2026/03/20 11:08:00 UTC

[jira] [Resolved] (KUDU-3749) Fix range_key_begin hex encoding to avoid signed-char sign extension

     [ https://issues.apache.org/jira/browse/KUDU-3749?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gabriella Lotz resolved KUDU-3749.
----------------------------------
    Fix Version/s: NA
       Resolution: Implemented

> Fix range_key_begin hex encoding to avoid signed-char sign extension
> --------------------------------------------------------------------
>
>                 Key: KUDU-3749
>                 URL: https://issues.apache.org/jira/browse/KUDU-3749
>             Project: Kudu
>          Issue Type: Bug
>            Reporter: Gabriella Lotz
>            Assignee: Gabriella Lotz
>            Priority: Major
>             Fix For: NA
>
>
> ksck, auto_rebalancer, and PartitionKey::DebugString() hex‑encode range/hash keys by streaming raw bytes into ostringstream. If char is signed and the range key contains bytes ≥ 0x80, the current static_cast<uint16_t>(key[i]) will sign‑extend, producing incorrect hex output (e.g., ff becomes ffff). This is a correctness issue in the encoded representation and can lead to inconsistent range tags between components.
> Proposed fix: Use an unsigned byte cast before widening in both places, e.g.:
> static_cast<uint16_t>(static_cast<uint8_t>(key[i]))
> or an equivalent helper to ensure 0–255 semantics.
> Locations:
> src/kudu/tools/ksck.cc (range_key_begin formatting)
> src/kudu/master/auto_rebalancer.cc (range_key_begin formatting)
> src/kudu/common/partition.cc (PartitionKey::DebugString())



--
This message was sent by Atlassian Jira
(v8.20.10#820010)