From f193d8ca59b493f468a47f8fccf717582dbda187 Mon Sep 17 00:00:00 2001 From: JoshuaMoelans <60878493+JoshuaMoelans@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:19:58 +0200 Subject: [PATCH 1/2] fix: adjusted memcpy size param to match remaining destination size --- src/path/sentry_path_windows.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/path/sentry_path_windows.c b/src/path/sentry_path_windows.c index b55ebbdf3..ceae9e979 100644 --- a/src/path/sentry_path_windows.c +++ b/src/path/sentry_path_windows.c @@ -164,14 +164,14 @@ sentry__path_join_wstr(const sentry_path_t *base, const wchar_t *other) return sentry__path_from_wstr(other); } else if (other[0] == L'/' || other[0] == L'\\') { if (isalpha(base->path[0]) && base->path[1] == L':') { - size_t len = wcslen(other) + 3; - sentry_path_t *rv = path_with_len(len); + size_t other_len = wcslen(other); + sentry_path_t *rv = path_with_len(other_len + 3); if (!rv) { return NULL; } rv->path[0] = base->path[0]; rv->path[1] = L':'; - memcpy(rv->path + 2, other, sizeof(wchar_t) * len); + memcpy(rv->path + 2, other, sizeof(wchar_t) * other_len); return rv; } else { return sentry__path_from_wstr(other); From ea858f6872d0c4bd46665c0a2bb04b70164be639 Mon Sep 17 00:00:00 2001 From: JoshuaMoelans <60878493+JoshuaMoelans@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:03:38 +0200 Subject: [PATCH 2/2] fix: add null termination character --- src/path/sentry_path_windows.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/path/sentry_path_windows.c b/src/path/sentry_path_windows.c index ceae9e979..95f71db9b 100644 --- a/src/path/sentry_path_windows.c +++ b/src/path/sentry_path_windows.c @@ -172,6 +172,7 @@ sentry__path_join_wstr(const sentry_path_t *base, const wchar_t *other) rv->path[0] = base->path[0]; rv->path[1] = L':'; memcpy(rv->path + 2, other, sizeof(wchar_t) * other_len); + rv->path[other_len + 2] = L'\0'; return rv; } else { return sentry__path_from_wstr(other);