New issue
Advanced search Search tips

Issue 764853 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 1
Type: Bug



Sign in to add a comment

Bitmask calculation in AutofillProfile::SetValidityFromBitfieldValue is suspicious

Project Member Reported by dcheng@chromium.org, Sep 13 2017

Issue description

// Compute the bitmask based on the number a bits per type. For example, this
// could be the two least significant bits (0b11).
const int kBitmask = 2 ^ validity_bits_per_type - 1;

This is doing a xor. I'm guessing this should be (2 << validity_bits_per_type) - 1 (and of course, validity_bits_per_type can never be the size of the type in bits either, since the left shift will overflow).
 

Comment 1 by se...@chromium.org, Sep 13 2017

Status: Started (was: Assigned)
Thanks!

Yeah it was a lucky coincidence that it worked for this value of validity_bits_per_type. Fortunately, the tests would have failed for a different value.

Thanks for finding this.
Project Member

Comment 2 by bugdroid1@chromium.org, Sep 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2f8d30f216e14e40ccce6c9e73fff47f5c0ae255

commit 2f8d30f216e14e40ccce6c9e73fff47f5c0ae255
Author: sebsg <sebsg@chromium.org>
Date: Wed Sep 13 21:25:53 2017

[Autofill] Use bitshift when computing validity bitmask.

Bug:  764853 
Change-Id: I6d115095dca728441100f6255a18bbc83a375502
Reviewed-on: https://chromium-review.googlesource.com/665385
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501753}
[modify] https://crrev.com/2f8d30f216e14e40ccce6c9e73fff47f5c0ae255/components/autofill/core/browser/autofill_profile.cc

Comment 3 by se...@chromium.org, Sep 13 2017

Status: Fixed (was: Started)

Sign in to add a comment