summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 17:26:17 -0300
committerGabriel Schneider <[email protected]>2026-11-23 17:47:03 -0300
commit6de26a20a5fb547f3d032f6ae2062066f356a659 (patch)
treed732376e0f31260a1cf57660f7a534a144dec002 /test
parent2f3e7717dfa61421c71475130f540f9db6f7478c (diff)
downloadpardes-6de26a20a5fb547f3d032f6ae2062066f356a659.tar.gz
pardes-6de26a20a5fb547f3d032f6ae2062066f356a659.zip
numbers from outside are checked where they are read: a diff's hunk header, a place's line and column, a PDF's page size (the failing runs first, kept in the scratch): core/fuzz.zig gains two fuzzes, "a diff's hunk headers with numbers past any file's: drawn, formatted and looked at, never a panic" (each seed a diff whose `@@` numbers are drawn from around and past every int width, drawn as a `.diff`, formatted as the patch view, looked at on every row) and "a language server's rows and a typed Look with numbers past any file's: landed, stepped and drawn, never a panic" (rows as lsp.sourceSpanRow writes them for seven kinds of answer, landed, stepped with n N j k Enter, drawn; the same places typed to Look in its three spellings); on the base the first panicked at core/diff.zig:134 (`w.new_at += 1`, integer overflow: a `.diff`, or a `cat` of one in a terminal, with `@@ -1 +18446744073709551615 @@` killed the session and every client that drew it) and the second at core/look.zig:751 (`@intCast(at.col - 1)`, integer does not fit: `Look /test.txt:1:3000000000` typed, or such text B3'd anywhere, a server's row with a column past i32 looked at); the language server's own rows land through Query's landing, which clamped already (its client validates each coordinate to a u32); FIXES: core/diff.zig `number` reads a header's number as a u32 (a line or a count of lines: no file pardes opens has more), one past it makes the row no header, drawn as text as patch(1) refuses it, so the walk's counts, hunks.zig `moved`'s i64 and jj.zig's u32 casts all hold; core/look.zig `focusPaneLine` takes a line past an i32 as no line and lands a column past its line's end at the end (`columnOn`, as a search's landing and Text.clampCursor have it: `Look x:2:9` on a 5-byte line lands at its end, where it stood past it before; a terminal's column, a jump's, as it was), the newly opened file's the same, and `selectSpan` saturates each number into cellRange, which clamps to the text; the pdf addon: a page's size is held where the bridge reads it (addons/pdf/pdf_bridge.c `pardes_pdf_get_page_size`, every size the layout sees comes through it) to `PARDES_PDF_MAX_PAGE_POINTS` (2^24 pt, 5.9 km, on a side; MuPDF bounds neither a MediaBox nor a UserUnit, nor a float's infinity) and the addon says so ("a page past 16777216 pt on a side: laid out at that size") when one lands: on the base a page 1e9 pt wide panicked the addon's paint (`@intFromFloat`, out of bounds, pdf.zig:413: the session and every client that drew it), test/pdf-fixtures/huge-pages.pdf (a 1e9 pt side, a side past a float, a UserUnit past a float, a page as any) opened, drawn, stepped and ended in the addon's script (addons/pdf/pdf.script, pdf.out); a test in core/look.zig of the landing itself; core-test Debug 950/1116 (166 skipped; base 947/1113), shell-test Debug 1162/1165 (3 skipped), addon-test Debug whole
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/pdf-fixtures/huge-pages.pdf61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/pdf-fixtures/huge-pages.pdf b/test/pdf-fixtures/huge-pages.pdf
new file mode 100644
index 00000000..f2d73a14
--- /dev/null
+++ b/test/pdf-fixtures/huge-pages.pdf
@@ -0,0 +1,61 @@
+%PDF-1.4
+1 0 obj
+<< /Type /Catalog /Pages 2 0 R >>
+endobj
+2 0 obj
+<< /Type /Pages /Kids [3 0 R 5 0 R 7 0 R 9 0 R] /Count 4 >>
+endobj
+3 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 1000000000 792] /Contents 4 0 R >>
+endobj
+4 0 obj
+<< /Length 17 >>
+stream
+0 0 m 100 100 l S
+endstream
+endobj
+5 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 1000000000000000000000000000000000000000000000 1000000000000000000000000000000000000000000000] /Contents 6 0 R >>
+endobj
+6 0 obj
+<< /Length 17 >>
+stream
+0 0 m 100 100 l S
+endstream
+endobj
+7 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /UserUnit 1000000000000000000000000000000000000 /Contents 8 0 R >>
+endobj
+8 0 obj
+<< /Length 17 >>
+stream
+0 0 m 100 100 l S
+endstream
+endobj
+9 0 obj
+<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 10 0 R >>
+endobj
+10 0 obj
+<< /Length 17 >>
+stream
+0 0 m 100 100 l S
+endstream
+endobj
+xref
+0 11
+0000000000 65535 f
+0000000009 00000 n
+0000000058 00000 n
+0000000133 00000 n
+0000000227 00000 n
+0000000294 00000 n
+0000000467 00000 n
+0000000534 00000 n
+0000000669 00000 n
+0000000736 00000 n
+0000000824 00000 n
+trailer
+<< /Size 11 /Root 1 0 R >>
+startxref
+892
+%%EOF