BNetworkCookie: fix overflow in date computation.

Fix one of the two failing tests from the cookie testsuite.
This commit is contained in:
Adrien Destugues
2016-10-30 20:23:43 +01:00
parent a61218b10d
commit 2215451b39
+8 -1
View File
@@ -279,7 +279,14 @@ BNetworkCookie&
BNetworkCookie::SetMaxAge(int32 maxAge)
{
BDateTime expiration = BDateTime::CurrentDateTime(B_LOCAL_TIME);
expiration.SetTime_t(expiration.Time_t() + maxAge);
// Compute the expiration date (watch out for overflows)
int64_t date = expiration.Time_t();
date += (int64_t)maxAge;
if (date > INT_MAX)
date = INT_MAX;
expiration.SetTime_t(date);
return SetExpirationDate(expiration);
}