]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
kldxref: Avoid buffer overflows in parse_pnp_list
authorJessica Clarke <jrtc27@FreeBSD.org>
Thu, 15 Oct 2020 18:03:14 +0000 (18:03 +0000)
committerJessica Clarke <jrtc27@FreeBSD.org>
Thu, 15 Oct 2020 18:03:14 +0000 (18:03 +0000)
commita98fa52ec6a656f9b1d8c4b00722ebba15a0efef
tree7039bb5b6f2bc251e8819b52bf98c1821df40de0
parent43777a207df4289ba3cc0c16994ca4b6aae3adcf
kldxref: Avoid buffer overflows in parse_pnp_list

We convert a string like "W32:vendor/device" into "I:vendor;I:device",
where the output is longer than the input, but only allocate space equal
to the length of the input, leading to a buffer overflow.

Instead use open_memstream so we get a safe dynamically-grown buffer.

Found by: CHERI
Reviewed by: imp, jhb (mentor)
Approved by: imp, jhb (mentor)
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D26637
usr.sbin/kldxref/kldxref.c