• Ramil Kalimullin's avatar
    Fix for bug #42803: Field_bit does not have unsigned_flag field, · ee6dadf4
    Ramil Kalimullin authored
    can lead to bad memory access
    
    Problem: Field_bit is the only field which returns INT_RESULT
    and doesn't have unsigned flag. As it's not a descendant of the 
    Field_num, so using ((Field_num *) field_bit)->unsigned_flag may lead
    to unpredictable results.
    
    Fix: check the field type before casting.
    
    
    mysql-test/r/type_bit.result:
      Fix for bug #42803: Field_bit does not have unsigned_flag field,
      can lead to bad memory access
        - test result.
    mysql-test/t/type_bit.test:
      Fix for bug #42803: Field_bit does not have unsigned_flag field,
      can lead to bad memory access
        - test case.
    sql/opt_range.cc:
      Fix for bug #42803: Field_bit does not have unsigned_flag field,
      can lead to bad memory access
        - don't cast to (Field_num *) Field_bit, as it's not a Field_num
      descendant and is always unsigned by nature.
    ee6dadf4
opt_range.cc 303 KB