Skip to content

Commit b47139a

Browse files
authored
Merge 5577dbb into 5bcc0d8
2 parents 5bcc0d8 + 5577dbb commit b47139a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixed
6+
7+
- Use strlcpy to save session replay info path ()
8+
39
## 8.44.0-beta.1
410

511
### Fixes

Sources/Sentry/SentrySessionReplaySyncC.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ sentrySessionReplaySync_start(const char *const path)
2020
if (crashReplay.path != NULL) {
2121
free(crashReplay.path);
2222
}
23-
24-
crashReplay.path = malloc(strlen(path));
25-
strcpy(crashReplay.path, path);
23+
24+
size_t buffer_size = sizeof(char) * (strlen(path) + 1); //Add a byte for the null-terminator.
25+
crashReplay.path = malloc(buffer_size);
26+
if (crashReplay.path) {
27+
strlcpy(crashReplay.path, path, buffer_size);
28+
} else {
29+
crashReplay.path = NULL;
30+
SENTRY_ASYNC_SAFE_LOG_ERROR("Could not copy the path to save session replay in case of an error. File path: %s", path);
31+
}
2632
}
2733

2834
void
@@ -35,6 +41,11 @@ sentrySessionReplaySync_updateInfo(unsigned int segmentId, double lastSegmentEnd
3541
void
3642
sentrySessionReplaySync_writeInfo(void)
3743
{
44+
if (crashReplay.path == NULL){
45+
SENTRY_ASYNC_SAFE_LOG_ERROR("There is no path to write replay information");
46+
return;
47+
}
48+
3849
int fd = open(crashReplay.path, O_RDWR | O_CREAT | O_TRUNC, 0644);
3950

4051
if (fd < 1) {

0 commit comments

Comments
 (0)