Skip to content
Snippets Groups Projects
  • Ivan Poddubny's avatar
    23a798fe
    Astobj2: Correctly treat hash_fn returning INT_MIN · 23a798fe
    Ivan Poddubny authored
    The code in astobj2_hash.c wrongly assumed that abs(int) is always > 0.
    However, abs(INT_MIN) = INT_MIN and is still negative, as well as
    abs(INT_MIN) % num_buckets, and as a result this led to a crash.
    
    One way to trigger the bug is using host=::80 or 0.0.0.128 in peer
    configuration section in chan_sip or chan_iax.
    
    This patch takes the remainder before applying abs, so that bucket
    number is always in range.
    
    ASTERISK-25100 #close
    Reported by: Mark Petersen
    
    Change-Id: Id6981400ad526f47e10bcf7b847b62bd2785e899
    23a798fe
    History
    Astobj2: Correctly treat hash_fn returning INT_MIN
    Ivan Poddubny authored
    The code in astobj2_hash.c wrongly assumed that abs(int) is always > 0.
    However, abs(INT_MIN) = INT_MIN and is still negative, as well as
    abs(INT_MIN) % num_buckets, and as a result this led to a crash.
    
    One way to trigger the bug is using host=::80 or 0.0.0.128 in peer
    configuration section in chan_sip or chan_iax.
    
    This patch takes the remainder before applying abs, so that bucket
    number is always in range.
    
    ASTERISK-25100 #close
    Reported by: Mark Petersen
    
    Change-Id: Id6981400ad526f47e10bcf7b847b62bd2785e899