Skip to content

Commit

Permalink
Switch to sprintf for digest
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox committed Aug 13, 2024
1 parent 536de49 commit 58bcc1e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Source/santad/DataLayer/SNTRuleTable.mm
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,11 @@ - (NSString *)hashOfHashes {
[db executeQuery:@"SELECT identifier, state, type, timestamp FROM rules WHERE type!=?",
@(SNTRuleStateAllowTransitive)];
while ([rs next]) {
NSString *digest =
[NSString stringWithFormat:@"%@:%d:%d:%u", [rs stringForColumn:@"identifier"],
[rs intForColumn:@"state"], [rs intForColumn:@"type"],
[rs intForColumn:@"timestamp"]];

crc = crc32(crc, reinterpret_cast<const unsigned char *>(digest.UTF8String),
static_cast<uint32_t>(digest.length));
char digest[128];
uint32_t len = snprintf(
digest, 128, "%s:%d:%d:%u", [rs stringForColumn:@"identifier"].UTF8String,
[rs intForColumn:@"state"], [rs intForColumn:@"type"], [rs intForColumn:@"timestamp"]);
crc = crc32(crc, reinterpret_cast<const unsigned char *>(digest), len);
}
[rs close];
}];
Expand Down

0 comments on commit 58bcc1e

Please sign in to comment.