Re: A bug in MetaPost

luigi scarso <[email protected]> Mon, 30 Jun 2025 22:24:41 +0200
Newsgroups gmane.comp.tex.metapost
Message-ID <CAG5iGsD+fY_9xK-JHedUL0gD0ZLA2A1RUywztMRNZ+YZpw5FFQ@mail.gmail.com>
--===============3106337246278821203==
Content-Type: multipart/alternative; boundary="000000000000fa98620638cfd1a3"

--000000000000fa98620638cfd1a3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Mon, 30 Jun 2025 at 10:26, Bor Gro=C5=A1elj Simi=C4=87 via metapost <
[email protected]> wrote:

> Hi,
>
> I found a bug in MetaPost. In source/texk/web2c/mplibdir/mpxout.w, on
> line 581, there is a single unescaped '%' that is fed to fprintf as the
> format string in line 645. This is UB by the C standard. The problem is
> silently ignored by most *printf implementations, but not by the one in
> Musl libc, which is how I stumbled upon this bug.
>

Thank you very much for the report,
do you have a test file ?

--
luigi

--000000000000fa98620638cfd1a3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote g=
mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, 30 Jun =
2025 at 10:26, Bor Gro=C5=A1elj Simi=C4=87 via metapost &lt;<a href=3D"mail=
to:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli=
d rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I found a bug in MetaPost. In source/texk/web2c/mplibdir/mpxout.w, on<br>
line 581, there is a single unescaped &#39;%&#39; that is fed to fprintf as=
 the<br>
format string in line 645. This is UB by the C standard. The problem is<br>
silently ignored by most *printf implementations, but not by the one in<br>
Musl libc, which is how I stumbled upon this bug.<br></blockquote><div><br>=
</div><div>Thank you very much for the report,</div><div>do you have a test=
 file ?=C2=A0</div><div><br></div><div>--</div><div>luigi</div></div></div>

--000000000000fa98620638cfd1a3--

--===============3106337246278821203==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
http://tug.org/metapost/

--===============3106337246278821203==--