This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-12397-fa289c25d4095108ff36d3f1c85b4f9bfe032df5
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit 0df1b0a726589b28bce39e70f8597f23675465a1
Author: Jeffrey Vo <[email protected]>
AuthorDate: Sun Nov 22 18:08:21 2026 +0000

    minor: fix potential soundness hole in fsb dictionary builder (#12397)
    
    # Which issue does this PR close?
    
    <!--
    It is not necessary to raise an issue, but it is encouraged if it is a
    non-trivial
    enhancement/bug.
    
    If this PR relates to an existing issue, but does not fully resolve it,
    please change
    the wording below from "Closes #NNN" to "Relates to #NNN" or "Part of
    #NNN" to avoid
    false closing an issue.
    -->
    
    - N/A
    
    # Rationale for this change
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the
    issue then this section is not needed. Explaining clearly why changes
    are proposed
    helps reviewers understand your changes and offer better suggestions for
    fixes.
    
    Please try to explain the problem you are trying to solve in terms of
    the user-visible
    behavior, rather than the implementation.
    -->
    
    Fix a potential soundness issue, see comments for more details
    
    # What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here but it
    is
    sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    Refactoring code to avoid issue.
    
    # Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they
    covered by existing tests, if so identify these tests)?
    
    If this PR claims a performance improvement, please include evidence
    such as
    benchmark results.
    
    DO NOT simply paste a list of commands ran to verify the code; this is
    what our
    CI is for and it pollutes the PR. ONLY explain if testing was included
    with this
    PR, or why it wasn't.
    -->
    
    Existing tests for fsb dictionary builder
    
    # Are there any significant user-facing changes?
    
    <!--
    Significant user-facing changes include:
    - Breaking public API change
    - Significant change to existing functionality (e.g. function returns
    something different)
    
    These need to be explicitly called out to ensure we have proper
    documentation if
    required and to ensure we follow proper semantic versioning.
    
    DO NOT restate the changes of this PR; if a bug was fixed and already
    explained
    above, we don't need this to be restated as a user-facing change.
    -->
    
    No
---
 .../src/builder/fixed_size_binary_dictionary_builder.rs      | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs 
b/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs
index 0c12c09a78..3d95461ea3 100644
--- a/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs
+++ b/arrow-array/src/builder/fixed_size_binary_dictionary_builder.rs
@@ -202,9 +202,7 @@ impl<K> FixedSizeBinaryDictionaryBuilder<K>
 where
     K: ArrowDictionaryKeyType,
 {
-    fn get_or_insert_key(&mut self, value: impl AsRef<[u8]>) -> 
Result<K::Native, ArrowError> {
-        let value_bytes: &[u8] = value.as_ref();
-
+    fn get_or_insert_key(&mut self, value_bytes: &[u8]) -> Result<K::Native, 
ArrowError> {
         let state = &self.state;
         let storage = &mut self.values_builder;
         let hash = state.hash_one(value_bytes);
@@ -218,7 +216,7 @@ where
             )
             .or_insert_with(|| {
                 let idx = storage.len();
-                let _ = storage.append_value(value);
+                let _ = storage.append_value(value_bytes);
                 idx
             })
             .get();
@@ -234,7 +232,8 @@ where
     ///
     /// Returns an error if the new index would overflow the key type.
     pub fn append(&mut self, value: impl AsRef<[u8]>) -> Result<K::Native, 
ArrowError> {
-        if value.as_ref().len() != self.byte_width as usize {
+        let value = value.as_ref();
+        if value.len() != self.byte_width as usize {
             Err(ArrowError::InvalidArgumentError(format!(
                 "Invalid input length passed to FixedSizeBinaryBuilder. 
Expected {} got {}",
                 self.byte_width,
@@ -256,7 +255,8 @@ where
         value: impl AsRef<[u8]>,
         count: usize,
     ) -> Result<K::Native, ArrowError> {
-        if value.as_ref().len() != self.byte_width as usize {
+        let value = value.as_ref();
+        if value.len() != self.byte_width as usize {
             Err(ArrowError::InvalidArgumentError(format!(
                 "Invalid input length passed to FixedSizeBinaryBuilder. 
Expected {} got {}",
                 self.byte_width,

Reply via email to