From 3744bd2004110f418e09f9e61ee195ba9c20dc5b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 31 May 2026 18:10:44 -0700 Subject: [PATCH] fix another case --- ...000000,time:1310,execs:717,op:quick,pos:97 | 31 +++++++++++++++++++ test.zig | 1 + yaml.zig | 3 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97 diff --git a/fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97 b/fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97 new file mode 100644 index 0000000000000000000000000000000000000000..d01aa497fd17d3a07caa0d9064b6804130581e19 --- /dev/null +++ b/fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97 @@ -0,0 +1,31 @@ +id: g982zq6e8wsvnmduerpbf8787hu85brugmngn8wf +name: yaml +main: yaml.zig +license: MIT +description: " Yaml parser built on top of libyaml +dependencies: + - src: git https://github.com/yaml/libyaml tag-0.2.5 + id: 8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc + license: MIT + c_include_dirs: + - include + c_source_flags: + - -DYAML_VERSION_MAJOR=0 + - -DYAML_VERSION_MINOR=2 + - -DYAML_VERSION_PATCH=5 + - -DYAML_VERSION_STRING="0.2.5" + - -DYAML_DECLARE_STATIC=1 + c_source_files: + - src/api.c + - src/dumper.c + - src/emitter.c + - src/loader.c + - src/parser.c + - src/reader.c + - src/scanner.c + - src/writer.c + + - src: git https://github.com/nektro/zig-extras + +root_dependencies: + - src: git https://github.com/nektro/zig-expect diff --git a/test.zig b/test.zig index 6ca54a0ea74334e8194e7f12e30d630bdaffddf4..8823cb5baedfc45679a3c02db0a7b2621827b8d5 100644 --- a/test.zig +++ b/test.zig @@ -21,6 +21,7 @@ fn fuzzCase(embedfile_content: []const u8) void { // zig fmt: off test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:2049,execs:911,op:quick,pos:263")); } test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:6342,execs:4701,op:arith8,pos:55,val:+3")); } +test { fuzzCase(@embedFile("./fuzz/crashes/id:000000,sig:06,src:000000,time:1310,execs:717,op:quick,pos:97")); } // zig fmt: on fn parseTest(comptime basename: [:0]const u8) !void { diff --git a/yaml.zig b/yaml.zig index 746ac3e4120156869986d6888b2c3e234c9bc390..cfe04ed8f6909d2f872ad92c08f40389581ea525 100644 --- a/yaml.zig +++ b/yaml.zig @@ -268,7 +268,7 @@ pub const Parser = struct { pub const Error = std.mem.Allocator.Error || - error{ YamlUnexpectedToken, YamlEndOfStream }; + error{ YamlUnexpectedToken, YamlEndOfStream, YamlInvalidMultilineString }; fn parse_item(p: *Parser, start: ?Token) Error!Item { const tok = start orelse try p.next(); @@ -376,6 +376,7 @@ fn get_event_string(event: Token, p: *const Parser) ![:0]u8 { const lines = p.lines; if (sm.line != em.line) { const starter = lines[sm.line][sm.column..]; + if (starter.len > 1 and starter[0] == '"') return error.YamlInvalidMultilineString; std.debug.assert(starter.len == 1); switch (starter[0]) { '|' => { -- 2.54.0