Skip to content
Permalink
Browse files
ibuf_get_volume_buffered_hash(): Use a proper type cast
On 64-bit systems, the constant 1 would be 32-bit (int or unsigned)
by default. Cast the constant to ulint before shifting to avoid a
-fsanitize=undefined warning or any potential overflow.
  • Loading branch information
dr-m committed May 18, 2017
1 parent 9f57e59 commit a436e34
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
@@ -2895,8 +2895,7 @@ ibuf_get_volume_buffered_hash(
fold = ut_fold_binary(data, len);

hash += (fold / (CHAR_BIT * sizeof *hash)) % size;
bitmask = static_cast<ulint>(
1 << (fold % (CHAR_BIT * sizeof(*hash))));
bitmask = static_cast<ulint>(1) << (fold % (CHAR_BIT * sizeof(*hash)));

if (*hash & bitmask) {

@@ -2935,8 +2935,7 @@ ibuf_get_volume_buffered_hash(
fold = ut_fold_binary(data, len);

hash += (fold / (CHAR_BIT * sizeof *hash)) % size;
bitmask = static_cast<ulint>(
1 << (fold % (CHAR_BIT * sizeof(*hash))));
bitmask = static_cast<ulint>(1) << (fold % (CHAR_BIT * sizeof(*hash)));

if (*hash & bitmask) {

0 comments on commit a436e34

Please sign in to comment.