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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Apply the propagation context to events that already have contexts set, so that events captured with a local scope or with event-level contexts keep their trace. ([#1843](https://github.com/getsentry/sentry-native/pull/1843))
- Route libcurl debug output through the Sentry logger (`SENTRY_TRACE`) instead of writing to `stderr`. ([#1854](https://github.com/getsentry/sentry-native/pull/1854))
- NOTE: `sentry_options_set_debug(options, true)` no longer displays verbose libcurl debug output by default. To restore it, call `sentry_options_set_logger_level(options, SENTRY_LEVEL_TRACE)`.
- Windows: fix symlink detection used to prevent database cleanup from following symlinks in run and cache directories. ([#1857](https://github.com/getsentry/sentry-native/pull/1857))

## 0.15.3

Expand Down
17 changes: 15 additions & 2 deletions src/path/sentry_path_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,21 @@ sentry__path_is_symlink(const sentry_path_t *path)
return false;
}
const DWORD attributes = GetFileAttributesW(path_w);
return attributes != INVALID_FILE_ATTRIBUTES
&& (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
if (attributes == INVALID_FILE_ATTRIBUTES
|| (attributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0) {
return false;
}

// https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-point-tags
WIN32_FIND_DATAW data;
const HANDLE find_handle = FindFirstFileW(path_w, &data);
if (find_handle == INVALID_HANDLE_VALUE) {
return true;
}
Comment thread
jpnurmi marked this conversation as resolved.
FindClose(find_handle);

return (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0
&& IsReparseTagNameSurrogate(data.dwReserved0) != 0;
}

size_t
Expand Down
3 changes: 2 additions & 1 deletion src/sentry_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ bool sentry__path_ends_with(const sentry_path_t *path, const char *suffix);
bool sentry__path_is_dir(const sentry_path_t *path);

/**
* Return whether the path refers to a symlink.
* Return whether the path refers to a symlink. On Windows, this includes
* name-surrogate reparse points such as junctions.
*/
bool sentry__path_is_symlink(const sentry_path_t *path);

Expand Down
26 changes: 23 additions & 3 deletions tests/unit/test_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,27 @@
#include "sentry_string.h"
#include "sentry_testsupport.h"

#if defined(SENTRY_PLATFORM_UNIX) && !defined(SENTRY_PLATFORM_NX) \
#if defined(SENTRY_PLATFORM_WINDOWS) && !defined(SENTRY_PLATFORM_XBOX)
static int
symlink(const char *target, const char *link)
{
sentry_path_t *target_path = sentry__path_from_str(target);
sentry_path_t *link_path = sentry__path_from_str(link);
if (!target_path || !link_path) {
sentry__path_free(link_path);
sentry__path_free(target_path);
return -1;
}

BOOLEAN success
= CreateSymbolicLinkW(link_path->path_w, target_path->path_w,
SYMBOLIC_LINK_FLAG_DIRECTORY
| SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE);
sentry__path_free(link_path);
sentry__path_free(target_path);
return success ? 0 : -1;
}
#elif defined(SENTRY_PLATFORM_UNIX) && !defined(SENTRY_PLATFORM_NX) \
&& !defined(SENTRY_PLATFORM_PS)
# include <unistd.h>
#endif
Expand Down Expand Up @@ -254,8 +274,8 @@ SENTRY_TEST(path_directory)

SENTRY_TEST(path_remove_all_symlink)
{
#if !defined(SENTRY_PLATFORM_UNIX) || defined(SENTRY_PLATFORM_NX) \
|| defined(SENTRY_PLATFORM_PS)
#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) \
|| defined(SENTRY_PLATFORM_XBOX)
SKIP_TEST();
#else
sentry_path_t *base
Expand Down
Loading