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

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.