]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
openat2: Fix invalid memory access on Cygwin.
authorBruno Haible <bruno@clisp.org>
Sat, 1 Nov 2025 12:37:35 +0000 (13:37 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 1 Nov 2025 12:37:35 +0000 (13:37 +0100)
* lib/openat2.c (do_openat2): Don't use an expression with side effects
as argument of ISSLASH.

ChangeLog
lib/openat2.c

index 8d0aa9f023af70a04b8eb337bb89f5f824c44a17..116b967c541c84ea4b87e12ff3b59602b4988ed9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-11-01  Bruno Haible  <bruno@clisp.org>
+
+       openat2: Fix invalid memory access on Cygwin.
+       * lib/openat2.c (do_openat2): Don't use an expression with side effects
+       as argument of ISSLASH.
+
 2025-11-01  Bruno Haible  <bruno@clisp.org>
 
        openat2 tests: Avoid gratuitous test failure when debugging.
index ee64d058365c371bee32401371df46f7627dec19..4ad4e88f6c3efbe0b679cb3ce4f55f052db587f5 100644 (file)
@@ -267,8 +267,12 @@ do_openat2 (int *fd, char const *filename,
             }
         }
       idx_t h = g;
-      while (1 < h && !ISSLASH (e[- --h]))
-        continue;
+      while (h > 1)
+        {
+          h--;
+          if (ISSLASH (e[-h]))
+            break;
+        }
 
       /* Properties of the file name through the first component's end,
          or to file name end if there is no component.  */