Add missing overflow handling to base::RandInt().

The result of RandGenerator() could return a number as high as UINT_MAX,
so casting that to int and adding it to another int will in general overflow.
Overflow is undefined behavior for signed integers, so add some type casting
to make sure this doesn't happen.

The DCHECKs in RandInt() where catching that something fishy was going on
(see bug), so as test just call RandInt() a few times with large bounds.
This test made the DCHECK reliably fire without the fix.

BUG=548375
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1419703005 .

Cr-Commit-Position: refs/heads/master@{#356939}
2 files changed