aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Paul Beusterien <paulbeusterien@google.com>2018-06-25 10:49:10 -0700
committerGravatar GitHub <noreply@github.com>2018-06-25 10:49:10 -0700
commit16132541d439baa9a1f80bb2b9b004f7178cba4d (patch)
tree84401d4a1576a56b23e010936ba1195b3620b4f1 /Firebase
parent19e0c0bb6ab4e3fdbc72acf9bd967e1ffaa3866d (diff)
Fix undefined behavior sanitizer issues in RTDB (#1445)
Diffstat (limited to 'Firebase')
-rw-r--r--Firebase/Database/Api/FIRDatabaseQuery.m2
-rw-r--r--Firebase/Database/Persistence/FLevelDBStorageEngine.m4
-rw-r--r--Firebase/Database/Snapshot/FIndexedNode.m2
3 files changed, 4 insertions, 4 deletions
diff --git a/Firebase/Database/Api/FIRDatabaseQuery.m b/Firebase/Database/Api/FIRDatabaseQuery.m
index eedc735..de18a7c 100644
--- a/Firebase/Database/Api/FIRDatabaseQuery.m
+++ b/Firebase/Database/Api/FIRDatabaseQuery.m
@@ -253,7 +253,7 @@ priorityMethodCalled:(BOOL)priorityMethodCalled {
if (limit == 0) {
[NSException raise:INVALID_QUERY_PARAM_ERROR format:@"Limit can't be zero"];
}
- if (limit >= 1l<<31) {
+ if (limit >= 1ul<<31) {
[NSException raise:INVALID_QUERY_PARAM_ERROR format:@"Limit must be less than 2,147,483,648"];
}
}
diff --git a/Firebase/Database/Persistence/FLevelDBStorageEngine.m b/Firebase/Database/Persistence/FLevelDBStorageEngine.m
index e49d6bc..68254ad 100644
--- a/Firebase/Database/Persistence/FLevelDBStorageEngine.m
+++ b/Firebase/Database/Persistence/FLevelDBStorageEngine.m
@@ -672,7 +672,7 @@ static NSString* trackedQueryKeysKey(NSUInteger trackedQueryId, NSString *key) {
return [data subdataWithRange:NSMakeRange(1, data.length - 2)];
}
-- (id)fixDoubleParsing:(id)value {
+- (id)fixDoubleParsing:(id)value __attribute__((no_sanitize("float-cast-overflow"))) {
// The parser for double values in JSONSerialization at the root takes some short-cuts and delivers wrong results
// (wrong rounding) for some double values, including 2.47. Because we use the exact bytes for hashing on the server
// this will lead to hash mismatches. The parser of NSNumber seems to be more in line with what the server expects,
@@ -683,7 +683,7 @@ static NSString* trackedQueryKeysKey(NSUInteger trackedQueryId, NSString *key) {
// The NSJSON parser returns all numbers as double values, even those that contain no exponent. To
// make sure that the String conversion below doesn't unexpectedly reduce precision, we make sure that
// our number is indeed not an integer.
- if ((double)(long long)[value doubleValue] != [value doubleValue]) {
+ if ((double)(int64_t)[value doubleValue] != [value doubleValue]) {
NSString *doubleString = [value stringValue];
return [NSNumber numberWithDouble:[doubleString doubleValue]];
} else {
diff --git a/Firebase/Database/Snapshot/FIndexedNode.m b/Firebase/Database/Snapshot/FIndexedNode.m
index e874dcf..9dc60e1 100644
--- a/Firebase/Database/Snapshot/FIndexedNode.m
+++ b/Firebase/Database/Snapshot/FIndexedNode.m
@@ -79,7 +79,7 @@ static FImmutableSortedSet *FALLBACK_INDEX;
if ([self.index isEqual:[FKeyIndex keyIndex]]) {
self.indexed = [FIndexedNode fallbackIndex];
} else {
- __block BOOL sawChild;
+ __block BOOL sawChild = NO;
[self.node enumerateChildrenUsingBlock:^(NSString *key, id<FNode> node, BOOL *stop) {
sawChild = sawChild || [self.index isDefinedOn:node];
*stop = sawChild;