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 bookpull/9842/head
parent
08c9661683
commit
ed1d77d518
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue