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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixed

- Use strlcpy to save session replay info path (#4740)

## 8.44.0-beta.1

### Fixes
Expand Down
17 changes: 15 additions & 2 deletions Sources/Sentry/SentrySessionReplaySyncC.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@
free(crashReplay.path);
}

crashReplay.path = malloc(strlen(path));
strcpy(crashReplay.path, path);
size_t buffer_size = sizeof(char) * (strlen(path) + 1); // Add a byte for the null-terminator.
crashReplay.path = malloc(buffer_size);
if (crashReplay.path) {
strlcpy(crashReplay.path, path, buffer_size);
} else {
crashReplay.path = NULL;

Check warning on line 29 in Sources/Sentry/SentrySessionReplaySyncC.c

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentrySessionReplaySyncC.c#L29

Added line #L29 was not covered by tests
SENTRY_ASYNC_SAFE_LOG_ERROR(
"Could not copy the path to save session replay in case of an error. File path: %s",
path);

Check warning on line 32 in Sources/Sentry/SentrySessionReplaySyncC.c

View check run for this annotation

Codecov / codecov/patch

Sources/Sentry/SentrySessionReplaySyncC.c#L31-L32

Added lines #L31 - L32 were not covered by tests
}
}

void
Expand All @@ -35,6 +43,11 @@
void
sentrySessionReplaySync_writeInfo(void)
{
if (crashReplay.path == NULL) {
SENTRY_ASYNC_SAFE_LOG_ERROR("There is no path to write replay information");
return;
}

int fd = open(crashReplay.path, O_RDWR | O_CREAT | O_TRUNC, 0644);

if (fd < 1) {
Expand Down
Loading