<div dir="ltr">Dear TeX Live team,<br><br>I encountered a segmentation fault while compiling a TeX document using `latexmk`. The issue occurred during the conversion from `.xdv` to `.pdf` by `xdvipdfmx`.<br><br>```<br>$ xdvipdfmx -q -E -o "build/main.pdf"  "build/main.xdv"<br>[1]    1747013 segmentation fault (core dumped)  xdvipdfmx -q -E -o "build/main.pdf" "build/main.xdv"<br>```<br><br>After pulling the latest TeX Live source and building in debug mode, I traced the fault to an out-of-bounds read in the `skip_white` function in `texk/dvipdfm-x/pdfparse.c`. This function attempts to skip whitespace characters between `start` and `end` address range, but in this case, the `end` pointer was invalid and pointed outside of the actual stream buffer. As the `start` pointer incremented, it eventually dereferenced an invalid address, causing the crash.<br><br>Looking at the caller, the faulty `end` pointer originates from the `pdf_get_object` function in `texlive/texk/dvipdfm-x/pdfobj.c`. Specifically, the expression on line 3648:<br><br>```c<br>q = p + (index == n-1 ? length : first + data[2*index+3]);<br>```<br><br>It calculates q relative to the start of the stream buffer (p), rather than the base pointer returned by pdf_stream_dataptr(objstm). This results in a pointer that may exceed the stream's actual bounds.<br>I propose the following fix:<br><br>```<br>q = (const char *) pdf_stream_dataptr(objstm) + (index == n-1 ? length : first + data[2*index+3]);<br>```<br><br>This correction ensures that q stays within the valid memory range of the object stream. After applying this fix, I rebuilt and re-ran the xdvipdfmx with latexmk, and the segmentation fault no longer occurs.<br><br>Please find the patch attached. Let me know if any further changes or tests are needed.<br><br><br>Best regards,<br><br>Shuqiao Zhang<br><br><<a href="mailto:stevenjoezhang@gmail.com">stevenjoezhang@gmail.com</a>><br></div>