Bug 1074651 - Detect integer overflow in BaseTimeDuration::TicksFromMilliseconds; r=bz

This commit is contained in:
Brian Birtles 2014-10-02 15:14:12 +09:00
Родитель b0e7dc53e1
Коммит cf167e36af
5 изменённых файлов: 29 добавлений и 3 удалений

Просмотреть файл

@ -0,0 +1,4 @@
<!DOCTYPE html>
<html style="transition-duration: 500000000000000000ms">
<body onload="document.documentElement.style.strokeWidth = '17px';"></body>
</html>

Просмотреть файл

@ -108,5 +108,6 @@ load 992333-1.html
pref(dom.webcomponents.enabled,true) load 1017798-1.html
load 1028514-1.html
load 1066089-1.html
load 1074651-1.html
load large_border_image_width.html
load border-image-visited-link.html

Просмотреть файл

@ -103,7 +103,14 @@ int64_t
BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds)
{
NS_ABORT_IF_FALSE(gInitialized, "calling TimeDuration too early");
return (aMilliseconds * kNsPerMsd) / sNsPerTick;
double result = (aMilliseconds * kNsPerMsd) / sNsPerTick;
if (result > INT64_MAX) {
return INT64_MAX;
} else if (result < INT64_MIN) {
return INT64_MIN;
}
return result;
}
int64_t

Просмотреть файл

@ -152,7 +152,14 @@ BaseTimeDurationPlatformUtils::ToSecondsSigDigits(int64_t aTicks)
int64_t
BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds)
{
return aMilliseconds * kNsPerMsd;
double result = aMilliseconds * kNsPerMsd;
if (result > INT64_MAX) {
return INT64_MAX;
} else if (result < INT64_MIN) {
return INT64_MIN;
}
return result;
}
int64_t

Просмотреть файл

@ -434,7 +434,14 @@ BaseTimeDurationPlatformUtils::ToSecondsSigDigits(int64_t aTicks)
int64_t
BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds)
{
return ms2mt(aMilliseconds);
double result = ms2mt(aMilliseconds);
if (result > INT64_MAX) {
return INT64_MAX;
} else if (result < INT64_MIN) {
return INT64_MIN;
}
return result;
}
int64_t