File: git-rename.diff

package info (click to toggle)
glibc 2.41-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300,384 kB
  • sloc: ansic: 1,050,583; asm: 238,243; makefile: 20,379; python: 13,537; sh: 11,827; cpp: 5,197; awk: 1,795; perl: 317; yacc: 292; pascal: 182; sed: 19
file content (47 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
commit 2ae4ec56c2b18c46ef8220bcddac4303a4b6ef1c
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Mon May 12 01:52:51 2025 +0200

    hurd: Make rename refuse trailing slashes [BZ #32570]
    
    As tested by Gnulib's renameatu module.
    
    Reported by Collin Funk on
    https://sourceware.org/bugzilla/show_bug.cgi?id=32570

diff --git a/sysdeps/mach/hurd/renameat2.c b/sysdeps/mach/hurd/renameat2.c
index 59a4e314fc..5b09fedf7f 100644
--- a/sysdeps/mach/hurd/renameat2.c
+++ b/sysdeps/mach/hurd/renameat2.c
@@ -37,15 +37,28 @@ __renameat2 (int oldfd, const char *old, int newfd, const char *new,
   if (flags & RENAME_NOREPLACE)
     excl = 1;
 
-  olddir = __directory_name_split_at (oldfd, old, (char **) &oldname);
+  olddir = __file_name_split_at (oldfd, old, (char **) &oldname);
   if (olddir == MACH_PORT_NULL)
     return -1;
-  newdir = __directory_name_split_at (newfd, new, (char **) &newname);
+  if (!*oldname)
+    {
+      /* Trailing slash.  */
+      __mach_port_deallocate (__mach_task_self (), olddir);
+      return __hurd_fail (ENOTDIR);
+    }
+  newdir = __file_name_split_at (newfd, new, (char **) &newname);
   if (newdir == MACH_PORT_NULL)
     {
-       __mach_port_deallocate (__mach_task_self (), olddir);
+      __mach_port_deallocate (__mach_task_self (), olddir);
       return -1;
     }
+  if (!*newname)
+    {
+      /* Trailing slash.  */
+      __mach_port_deallocate (__mach_task_self (), olddir);
+      __mach_port_deallocate (__mach_task_self (), newdir);
+      return __hurd_fail (ENOTDIR);
+    }
 
   err = __dir_rename (olddir, oldname, newdir, newname, excl);
   __mach_port_deallocate (__mach_task_self (), olddir);