Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions mettle/src/stdapi/fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,17 @@ fs_mkdir(struct tlv_handler_ctx *ctx)
return tlv_packet_response_result(ctx, TLV_RESULT_ENOMEM);
}

// take into account null byte at the end of path and the one we add in sprintf
base_dir = malloc(strlen(path_dup)+2);
// take into account null byte at the end of path and the one we add in snprintf
size_t base_max_len = strlen(path_dup) + 2;
base_dir = malloc(base_max_len);

if(base_dir == NULL)
{
free(path_dup);
return tlv_packet_response_result(ctx, TLV_RESULT_ENOMEM);
}

tmp = malloc(strlen(path_dup)+2);
tmp = malloc(base_max_len);

if(tmp == NULL)
{
Expand All @@ -579,15 +580,22 @@ fs_mkdir(struct tlv_handler_ctx *ctx)
}

dir = strtok(path_dup, "/");

if(dir == NULL) {
free(tmp);
free(path_dup);
free(base_dir);
return tlv_packet_response_result(ctx, TLV_RESULT_EINVAL);
}

//address absolute paths — check original path since strtok modifies path_dup
if (path[0] == '/')
{
sprintf(base_dir, "/%s/", dir);
snprintf(base_dir, base_max_len, "/%s/", dir);
}
Comment thread
dledda-r7 marked this conversation as resolved.
else
{
sprintf(base_dir, "%s/", dir);
snprintf(base_dir, base_max_len, "%s/", dir);
}

while(dir != NULL)
Expand All @@ -614,7 +622,7 @@ fs_mkdir(struct tlv_handler_ctx *ctx)
dir = strtok(NULL, "/");
if(dir != NULL)
{
sprintf(tmp, "%s%s/", base_dir, dir);
snprintf(tmp, base_max_len, "%s%s/", base_dir, dir);
strcpy(base_dir, tmp);
}
}
Expand Down
12 changes: 12 additions & 0 deletions mettle/src/stdapi/ui/osx_desktop.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
struct tlv_packet *p;
uint32_t quality = 0;
tlv_packet_get_u32(ctx->req, TLV_TYPE_DESKTOP_SCREENSHOT_QUALITY, &quality);

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 140000
if (@available(macOS 14.4, *)) {
// ScreenCaptureKit is required on macOS 14.4+ but is not yet implemented.
return tlv_packet_response_result(ctx, TLV_RESULT_FAILURE);
}
#endif

#if __MAC_OS_X_VERSION_MAX_ALLOWED < 150000
@autoreleasepool {
CGImageRef image = CGDisplayCreateImage(kCGDirectMainDisplay);
CFMutableDataRef newImageData = CFDataCreateMutable(NULL, 0);
Expand All @@ -26,4 +35,7 @@
}
}
return p;
#else
return tlv_packet_response_result(ctx, TLV_RESULT_FAILURE);
#endif
}
Loading