diff options
Diffstat (limited to 'build')
| -rw-r--r-- | build/patches.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/build/patches.zig b/build/patches.zig index 5e120345..d5ac7372 100644 --- a/build/patches.zig +++ b/build/patches.zig @@ -274,6 +274,14 @@ pub fn ghosttyKitty(b: *std.Build, patch: *std.Build.Step.Compile, dep: *std.Bui /// upstream). A class's range ending at `\xff` counted to 256 in a u8, an /// overflow (a panic in a safe build, a runaway loop in a fast one): /// `[\x80-\xff]` in any search took the editor down. +/// - compile() read past the end of a pattern that stops inside a count +/// (`a{`, `a{,1`, `a{1`, `a{1,`, `a{1,2`), a byte escape (`\x`, `{\\x`) +/// or a class (`[\`, `[\x`, `[\x41`, `[\\x]`): a panic in a safe build +/// on the second key of a search for `a{2}`; in a fast one the bytes +/// after the pattern decided what it meant, so a session and its client +/// could compile one typed pattern differently. Unreported upstream as +/// of 3efcfe33 (its trunk on 2026-11-19); docs/mvzr-bounds.md is the +/// report for it. const mvzr_edits = [_]Edit{ .{ .old = "fn matchPattern(patt: []const RegOp, sets: []const CharSet, haystack: []const u8, i_in: usize) ?OpMatch {\n", @@ -326,6 +334,17 @@ const mvzr_edits = [_]Edit{ \\ , }, + // A pattern cut short inside a count, a byte escape or a class: each + // read checks the pattern's end first (a bad string, as its other + // malformed patterns are). + .{ .old = "fn parseHex(in: []const u8) !u8 {\n", .new = "fn parseHex(in: []const u8) !u8 {\n if (in.len < 2) return error.BadString;\n" }, + .{ .old = " i += 1;\n if (in[i] == ',') { // {,?\n", .new = " i += 1;\n if (i == in.len) {\n bad_string = true;\n break :dispatch;\n }\n if (in[i] == ',') { // {,?\n" }, + .{ .old = " if (in[i] == '}') { // {,N}\n", .new = " if (i < in.len and in[i] == '}') { // {,N}\n" }, + .{ .old = " i += d1;\n if (in[i] == ',') { // {M,?\n i += 1;\n if (in[i] == '}') { // {M,}\n", .new = " i += d1;\n if (i == in.len) {\n bad_string = true;\n break :dispatch;\n }\n if (in[i] == ',') { // {M,?\n i += 1;\n if (i < in.len and in[i] == '}') { // {M,}\n" }, + .{ .old = " i += d2;\n if (in[i] != '}') {\n", .new = " i += d2;\n if (i == in.len or in[i] != '}') {\n" }, + .{ .old = "fn valueFor(in: []const u8) ?u8 {\n", .new = "fn valueFor(in: []const u8) ?u8 {\n if (in.len == 0) return null;\n" }, + .{ .old = " return parseHex(in[1..4]) catch return null;\n", .new = " return parseHex(in[1..3]) catch return null;\n" }, + .{ .old = " if (i == in.len or in[i] != ']') {\n return BadString;\n", .new = " if (i >= in.len or in[i] != ']') {\n return BadString;\n" }, .{ .old = "for (c1..c2 + 1) |c_range|", .new = "for (c1..@as(usize, c2) + 1) |c_range|" }, .{ .old = "[1]RegOp{.{ .unused = {} }} ** ops", .new = "@splat(.{ .unused = {} })" }, .{ .old = "[1]CharSet{.{ .low = 0, .hi = 0 }} ** char_sets", .new = "@splat(.{ .low = 0, .hi = 0 })" }, |
