santactl/fileinfo: Don't crash on <512b files

This commit is contained in:
Russell Hancox
2016-04-08 16:20:49 -04:00
parent 492e523884
commit 43434fd445

View File

@@ -210,7 +210,7 @@ extern NSString *const NSURLQuarantinePropertiesKey WEAK_IMPORT_ATTRIBUTE;
- (BOOL)isDMG {
NSUInteger last512 = self.fileSize - 512;
const char *magic = (const char *)[[self safeSubdataWithRange:NSMakeRange(last512, 4)] bytes];
return (strncmp("koly", magic, 4) == 0);
return (magic && strncmp("koly", magic, 4) == 0);
}
#pragma mark Page Zero