mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
fix(native): a trailing slash after a program keeps the hook's exe name like the kernel (#3171)
This commit is contained in:
1 parent
5ed97915c7
commit
9be131cf6d
2 files changed
+7
-2
No files matched your search
@@ -54,12 +54,11 @@ static void resolve_symlinks(const char *path, char *out, size_t out_size, int d
|
||||
if (used >= sizeof(done) - 1) return;
|
||||
if (!follow_link(done, link_target, sizeof(link_target))) {
|
||||
struct stat st;
|
||||
if (rest[strspn(rest, "/")] && (syscall(SYS_newfstatat, AT_FDCWD, done, &st, 0) != 0 || !S_ISDIR(st.st_mode))) return;
|
||||
if (*rest && (syscall(SYS_newfstatat, AT_FDCWD, done, &st, 0) != 0 || !S_ISDIR(st.st_mode))) return;
|
||||
continue;
|
||||
}
|
||||
if (++links > 40) return;
|
||||
size_t m = ddnatv_append(next_path, sizeof(next_path), 0, link_target, strlen(link_target));
|
||||
m = ddnatv_append(next_path, sizeof(next_path), m, "/", 1);
|
||||
m = ddnatv_append(next_path, sizeof(next_path), m, rest, strlen(rest));
|
||||
if (m >= sizeof(next_path) - 1) return;
|
||||
if (link_target[0] == '/') {
|
||||
|
||||
@@ -108,6 +108,12 @@ class NativeHookExecTargetTest(unittest.TestCase):
|
||||
def test_a_file_is_not_used_as_a_directory(self):
|
||||
self.assertNotEqual(self.real, self.exe("/opt/real/prog/../prog"))
|
||||
|
||||
def test_a_trailing_slash_after_a_program_is_not_dropped(self):
|
||||
self.assertNotEqual(self.real, self.exe("/opt/real/prog/"))
|
||||
|
||||
def test_a_trailing_slash_after_a_link_to_a_program_is_not_dropped(self):
|
||||
self.assertNotEqual(self.real, self.exe("/opt/link/"))
|
||||
|
||||
def test_a_proot_hard_link_keeps_its_own_name(self):
|
||||
self.assertEqual(str(self.root / "opt/real/hard"), self.exe("/opt/real/hard"))
|
||||
|
||||
|
||||
Reference in new issue
Block a user