Re: `infocmp -E` heap overflow in `safe_name()`

Thomas Dickey <[email protected]> Thu, 14 May 2026 04:06:51 -0400
Newsgroups gmane.comp.lib.ncurses.bugs
Message-ID <[email protected]>
On Wed, May 13, 2026 at 09:46:57PM -0400, Daniel Anderson wrote:
> Good evening,
> 
> I found a heap-buffer overflow in infocmp's safe_name().
> 
> `infocmp -x -E` can overflow a heap buffer when dumping a terminfo entry with
> a long extended capability name.  The bug is in
> `progs/infocmp.c:safe_name()`:  the function keeps a static pointer to a heap
> buffer, allocates it only on the first call, sizes it from that first call's
> arguments, and reuses it for later calls even when later names require more
> space.

agreed - it ought to check the length and reallocate as needed.
 
-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net
signature.asc (application/pgp-signature, 659 B)
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEGYgtkt2kxADCLA1WzCr0RyFnvgMFAmoFgpsACgkQzCr0RyFn
vgO4OgwAzU28vLJJvkPCaRjYqY9FnV7eU/OxaeqGI3kbnN59YMyb/JTd9t+Vm0p2
b8286q3fLzx+DBXFRdCcGfn9RCCqMDFOB979B4Tfozv2txU1LT0z/cIzm12S4G2O
rom691rQ2hUI16lyLXM3uJAzH2lQrkE6Kmz3/ULn4k51IDBvzr2AsLC1LnFTje/w
rM+R6GNHAAupGFXeR/aYj4tmOiVYHbTl0o5lOpop5P3odVqo99f75cKax7zruYmm
5r5io9Y8xaHxqoDu/8GnE0Tlenif8A2GrmSRuxAUEeDt79eTmEZ4NqmNEDQPI+B5
pzAmsLP3nVRCqkmvJab3+eR7QgGHEDN2mdchqj7reFvpzP62Z2HKRaalVFo87bT9
V1CRFCXBM84WKXLILkukeZSBxIJMgxZdLQZOFU2weNAINyHAaiMGWz6ABV4jarGt
IAHBxifYTy2UVms0nsiidTuecymYY5cL9cdATls/ePBJkso+pk90hriCzCxoIAlZ
IZwhKOea
=bh7B
-----END PGP SIGNATURE-----