Closed Bug 1085497 Opened 6 years ago Closed 6 years ago

Use typedef for the length of mozilla::pkix::Input/Reader for safer casting

Categories

(Core :: Security: PSM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: briansmith, Assigned: briansmith)

References

Details

Attachments

(1 file)

Attached patch size_type.patchSplinter Review
Let's say you want to compute the diference of lengths of to Inputs:

   Input::size_type diff;
   if (a.GetLength() > b.GetLength()) {
     // The cast is required because operator- returns a signed type.
     diff = static_cast<Input::size_type>(a.GetLength() - b.GetLength());
   }

We could just use "uint16_t" but that would be problematic if/when we need to change the maximum length of Input/Reader.
Attachment #8508064 - Flags: review?(mmc)
Attachment #8508064 - Flags: review?(mmc) → review+
https://hg.mozilla.org/mozilla-central/rev/9d83b21c98e8
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.