Bug #105511 1 << fold % 64UL left shift over 31bit may cause unexpect behaviour
Submitted: 10 Nov 2021 4:07 Modified: 10 Nov 2021 7:51
Reporter: WANG GUANGYOU Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[10 Nov 2021 4:07] WANG GUANGYOU
Description:
in ibuf_get_volume_buffered_hash
bitmask = static_cast<ulint>(
  1 << (fold % (CHAR_BIT * sizeof(*hash))));
because (fold % (CHAR_BIT * sizeof(*hash)))  <=63
and 1 is 32bit , it may cause unexpect behaviour

How to repeat:
use sonar to scan code

Suggested fix:
bitmask = static_cast<ulint>(
  1UL << (fold % (CHAR_BIT * sizeof(*hash))));

change 1 to 1UL
[10 Nov 2021 7:51] MySQL Verification Team
Hello WANG GUANGYOU,

Thank you for the report and feedback.

regards,
Umesh