summaryrefslogtreecommitdiffstats
path: root/location
diff options
context:
space:
mode:
authorLaurent Tu <laurentt@google.com>2012-10-04 13:40:08 -0700
committerLaurent Tu <laurentt@google.com>2012-10-04 13:40:08 -0700
commite72fe16146dd33cb218bf8c16b069f68f331fdf8 (patch)
tree1fc422742eaca00e3ae01f790bc188e6d480a012 /location
parent57e6203457cedbc6f4bf8a45635862a3eb717e9f (diff)
downloadframeworks_base-e72fe16146dd33cb218bf8c16b069f68f331fdf8.zip
frameworks_base-e72fe16146dd33cb218bf8c16b069f68f331fdf8.tar.gz
frameworks_base-e72fe16146dd33cb218bf8c16b069f68f331fdf8.tar.bz2
Prevent overflow in LocationRequest.setExpireIn()
Prevent overflow in LocationRequest.setExpireIn(), for example, when we pass in Long.MAX_VALUE. Bug: 7047435 Change-Id: Ie56928a59fb387173fbd3887c0ef9aede00f8152
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/LocationRequest.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/location/java/android/location/LocationRequest.java b/location/java/android/location/LocationRequest.java
index f4f7b09..cb291ea 100644
--- a/location/java/android/location/LocationRequest.java
+++ b/location/java/android/location/LocationRequest.java
@@ -369,7 +369,15 @@ public final class LocationRequest implements Parcelable {
* @return the same object, so that setters can be chained
*/
public LocationRequest setExpireIn(long millis) {
- mExpireAt = millis + SystemClock.elapsedRealtime();
+ long elapsedRealtime = SystemClock.elapsedRealtime();
+
+ // Check for > Long.MAX_VALUE overflow (elapsedRealtime > 0):
+ if (millis > Long.MAX_VALUE - elapsedRealtime) {
+ mExpireAt = Long.MAX_VALUE;
+ } else {
+ mExpireAt = millis + elapsedRealtime;
+ }
+
if (mExpireAt < 0) mExpireAt = 0;
return this;
}