Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox committed Aug 9, 2024
1 parent ea2b57f commit c503604
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/common/SNTFileInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<char *>(malloc(chunkSize));

@try {
CC_SHA1_CTX c1;
Expand Down
8 changes: 5 additions & 3 deletions Source/common/SNTRule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<SNTRuleState>([DECODE(NSNumber, @"state") intValue]);
_type = static_cast<SNTRuleType>([DECODE(NSNumber, @"type") intValue]);
_customMsg = DECODE(NSString, @"custommsg");
_customURL = DECODE(NSString, @"customurl");
_timestamp = [DECODE(NSNumber, @"timestamp") unsignedIntegerValue];
Expand Down Expand Up @@ -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<CC_LONG>(ruleData.length),
(unsigned char *)&digest);

return santa::SHA256DigestToNSString(digest);
}
Expand Down
4 changes: 3 additions & 1 deletion Source/santad/DataLayer/SNTRuleTable.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<CC_LONG>([digest lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
}
[rs close];
}];
Expand Down

0 comments on commit c503604

Please sign in to comment.