Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Guard size arithmetic when parsing envelopes and Linux OS release data, copying slices, and allocating memory during crash handling. ([#2059](https://github.com/getsentry/sentry-native/pull/2059))
- macOS: prevent out-of-bounds reads while parsing Mach-O load commands. ([#2065](https://github.com/getsentry/sentry-native/pull/2065))
- Prevent out-of-bounds reads when parsing JSON numbers from length-delimited buffers. ([#2067](https://github.com/getsentry/sentry-native/pull/2067))
- Native: prevent buffer attachments from being written outside their UUID run directory. ([#2072](https://github.com/getsentry/sentry-native/pull/2072))

**Thank you**:

Expand Down
19 changes: 13 additions & 6 deletions src/backends/sentry_backend_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,18 +1247,25 @@ ensure_attachment_path(sentry_attachment_t *attachment)
}
}

if (!base_path || sentry__path_create_dir_all(base_path) != 0) {
sentry__path_free(base_path);
if (!base_path) {
return false;
}

sentry_path_t *old_path = attachment->path;
attachment->path = sentry__path_join_str(
sentry_path_t *path = sentry__path_join_str(
base_path, sentry__path_filename(attachment->filename));
sentry_path_t *parent = path ? sentry__path_dir(path) : NULL;
bool valid = parent && sentry__path_eq(parent, base_path);
Comment thread
jpnurmi marked this conversation as resolved.
sentry__path_free(parent);
if (!valid || sentry__path_create_dir_all(base_path) != 0) {
sentry__path_free(path);
Comment thread
sentry[bot] marked this conversation as resolved.
sentry__path_free(base_path);
return false;
}

sentry__path_free(base_path);
sentry__path_free(old_path);
return attachment->path != NULL;
sentry__path_free(attachment->path);
Comment thread
sentry[bot] marked this conversation as resolved.
attachment->path = path;
return true;
}

static void
Expand Down
Loading