From ed1d77d518f58ca97895ff789c69b54d3a3bf1b4 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Sun, 7 Dec 2025 13:35:52 +0800 Subject: [PATCH] os: fix off-by-one error in ShellEscapeWriter I am truly not sure why the tests never caught this, but I just fell for the oldest trick in the book --- src/os/shell.zig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/os/shell.zig b/src/os/shell.zig index a6f23e843..7f3254d87 100644 --- a/src/os/shell.zig +++ b/src/os/shell.zig @@ -5,8 +5,6 @@ const Writer = std.Io.Writer; /// Writer that escapes characters that shells treat specially to reduce the /// risk of injection attacks or other such weirdness. Specifically excludes /// linefeeds so that they can be used to delineate lists of file paths. -/// -/// T should be a Zig type that follows the `std.Io.Writer` interface. pub const ShellEscapeWriter = struct { writer: Writer, child: *Writer, @@ -33,7 +31,7 @@ pub const ShellEscapeWriter = struct { var count: usize = 0; for (data[0 .. data.len - 1]) |chunk| try self.writeEscaped(chunk, &count); - for (0..splat) |_| try self.writeEscaped(data[data.len], &count); + for (0..splat) |_| try self.writeEscaped(data[data.len - 1], &count); return count; }