]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
security: implement O_NOFOLLOW -ELOOP return (Fase 3)
authorTulio A M Mendes <[email protected]>
Tue, 26 May 2026 05:19:02 +0000 (02:19 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 05:52:27 +0000 (02:52 -0300)
src/kernel/syscall.c

index f0f45fe352de7ad6f5f9325e106014f663493caf..d62ba309ca1a3e9ac60002d815f817d40b2a2e30 100644 (file)
@@ -2351,6 +2351,10 @@ static int syscall_open_impl(const char* user_path, uint32_t flags) {
     fs_node_t* node;
     if (flags & 0x20000) { /* O_NOFOLLOW */
         node = vfs_lookup_nofollow(path);
+        /* If O_NOFOLLOW is set and the final component is a symlink, return -ELOOP */
+        if (node && node->flags == FS_SYMLINK) {
+            return -ELOOP;
+        }
     } else {
         node = vfs_lookup(path);
     }