Closed Bug 1127158 Opened 9 years ago Closed 8 years ago

Incorrect flag math in nsSecureBrowserUIImpl.cpp?

Categories

(Core :: Security: PSM, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: jduell.mcbugs, Assigned: Cykesiopka)

References

Details

(Whiteboard: [psm-assigned])

Attachments

(1 file)

What's up with all the '-=' operations on testFlags here?

   https://dxr.mozilla.org/mozilla-central/source/security/manager/boot/src/nsSecureBrowserUIImpl.cpp?from=nsSecureBrowserUIImpl.cpp#839

It looks like they should all be "& ~(FLAG)",  not "-= FLAG".  (These are boolean flags we're trying to filter out, so subtracting doesn't make sense.)

Also we don't ever user 'testArgs' so not sure of the point of that variable.

The same boolean flag math error applies to the 'f' variable as well:

   https://dxr.mozilla.org/mozilla-central/source/security/manager/boot/src/nsSecureBrowserUIImpl.cpp?from=nsSecureBrowserUIImpl.cpp#858
make that "&= ~(FLAG)", of course.
Hmm, I think it's _technically_ correct, because it's always checking that the flag is set before subtracting it.

But that seems like a horrible, horrible antipattern and should definitely be changed. Too easy to screw up and is conceptually wrong.
Hmm, this is all debug code. I wonder if anyone even uses it.
Blocks: 832834
(In reply to :Cykesiopka from comment #3)
> Hmm, this is all debug code. I wonder if anyone even uses it.

I'm going to assume no here and just remove this code.

Reasoning:
 - It's brittle, as mentioned in previous comments.
 - nsSecureBrowserUIImpl.cpp is already a huge pain to read. We don't need more clutter.
 - As more code gets landed all over the tree to support features, stuff like this need to go away so rising compile times are mitigated.

If you do use this code, please maintain a local patch instead.
Assignee: nobody → cykesiopka.bmo
Severity: normal → minor
Status: NEW → ASSIGNED
Component: Security → Security: PSM
OS: Linux → All
Hardware: x86 → All
Whiteboard: [psm-assigned]
Comment on attachment 8737396 [details]
MozReview Request: Bug 1127158 - Remove brittle debug only flag math in nsSecureBrowserUIImpl.cpp.

https://reviewboard.mozilla.org/r/43791/#review40743

Yeah, let's just get rid of this.
Attachment #8737396 - Flags: review?(dkeeler) → review+
https://hg.mozilla.org/mozilla-central/rev/8cdccb1dd539
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: