Skip to content

Commit

Permalink
fix: CWE-789 vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Nov 2, 2023
1 parent dc10c8a commit 47896ab
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions GrowingTrackerCore/Utils/GrowingDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ - (NSString *)getDeviceIdString {
return uuid;
}

+ (NSString *)getSysInfoByName:(char *)typeSpeifier {
+ (NSString *)getSysInfoByName:(char *)name {
size_t size;
sysctlbyname(typeSpeifier, NULL, &size, NULL, 0);
char *answer = (char *)malloc(size);
sysctlbyname(typeSpeifier, answer, &size, NULL, 0);
NSString *results = [NSString stringWithCString:answer encoding:NSUTF8StringEncoding];
if (results == nil) {
results = @"";
NSString *results = nil;
if (sysctlbyname(name, NULL, &size, NULL, 0) == 0) {
char *machine = calloc(1, size);
if (sysctlbyname(name, machine, &size, NULL, 0) == 0) {
results = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
}
free(machine);
}
free(answer);
return results;
return results ?: @"";
}

#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
Expand Down

0 comments on commit 47896ab

Please sign in to comment.