From c50360495a2995a09d5a48ea54d41f2403d0eac2 Mon Sep 17 00:00:00 2001 From: Russell Hancox Date: Fri, 9 Aug 2024 12:17:37 -0400 Subject: [PATCH] Feedback --- Source/common/SNTFileInfo.mm | 2 +- Source/common/SNTRule.mm | 8 +++++--- Source/santad/DataLayer/SNTRuleTable.mm | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/common/SNTFileInfo.mm b/Source/common/SNTFileInfo.mm index dd36c8046..34f0b010c 100644 --- a/Source/common/SNTFileInfo.mm +++ b/Source/common/SNTFileInfo.mm @@ -164,7 +164,7 @@ - (instancetype)initWithPath:(NSString *)path { - (void)hashSHA1:(NSString **)sha1 SHA256:(NSString **)sha256 { const int MAX_CHUNK_SIZE = 256 * 1024; // 256 KB const size_t chunkSize = _fileSize > MAX_CHUNK_SIZE ? MAX_CHUNK_SIZE : _fileSize; - char *chunk = (char *)malloc(chunkSize); + char *chunk = static_cast(malloc(chunkSize)); @try { CC_SHA1_CTX c1; diff --git a/Source/common/SNTRule.mm b/Source/common/SNTRule.mm index ad8e9cd60..b45f2d28b 100644 --- a/Source/common/SNTRule.mm +++ b/Source/common/SNTRule.mm @@ -229,8 +229,8 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super init]; if (self) { _identifier = DECODE(NSString, @"identifier"); - _state = (SNTRuleState)[DECODE(NSNumber, @"state") intValue]; - _type = (SNTRuleType)[DECODE(NSNumber, @"type") intValue]; + _state = static_cast([DECODE(NSNumber, @"state") intValue]); + _type = static_cast([DECODE(NSNumber, @"type") intValue]); _customMsg = DECODE(NSString, @"custommsg"); _customURL = DECODE(NSString, @"customurl"); _timestamp = [DECODE(NSNumber, @"timestamp") unsignedIntegerValue]; @@ -313,7 +313,9 @@ - (NSString *)digest { NSData *ruleData = [ruleDigestFormat dataUsingEncoding:NSUTF8StringEncoding]; unsigned char digest[CC_SHA256_DIGEST_LENGTH]; - CC_SHA256(ruleData.bytes, (CC_LONG)ruleData.length, (unsigned char *)&digest); + CC_SHA256(ruleData.bytes, + static_cast(ruleData.length), + (unsigned char *)&digest); return santa::SHA256DigestToNSString(digest); } diff --git a/Source/santad/DataLayer/SNTRuleTable.mm b/Source/santad/DataLayer/SNTRuleTable.mm index 28b2a03ca..e353a04b9 100644 --- a/Source/santad/DataLayer/SNTRuleTable.mm +++ b/Source/santad/DataLayer/SNTRuleTable.mm @@ -601,7 +601,9 @@ - (NSString *)hashOfHashes { while ([rs next]) { SNTRule *r = [self ruleFromResultSet:rs]; NSString *digest = r.digest; - CC_SHA256_Update(&sha, digest.UTF8String, (CC_LONG)digest.length); + CC_SHA256_Update( + &sha, digest.UTF8String, + static_cast([digest lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); } [rs close]; }];