HomeFreeBSD

ifconfig: Fix invalid free() in ifbridge

Description

ifconfig: Fix invalid free() in ifbridge

parse_vlans() does 's = strdup(str)', then calls strsep(&s, ...), then
attempts to free(s) at the end of the function. For the success case,
this is fine (s is NULL, so it's a trivial memory leak), but in the
error case, we will attempt to free an invalid pointer.

Fix this by storing the original return value from strdup() and freeing
that instead.

Approved by: re (cperciva)
MFC after: 3 seconds
Reported by: David Gwynne <dlg@openbsd.org>
Reviewed by: zlei, kevans
Sponsored by: https://www.patreon.com/bsdivy
Differential Revision: https://reviews.freebsd.org/D53545

(cherry picked from commit 0899f7a3b791ed4878e7cb3859636ec980c76832)
(cherry picked from commit fe2e534433778c038138510ff6a8f07066e72703)

Details

Provenance
ivyAuthored on Nov 4 2025, 12:53 AM
cpercivaCommitted on Nov 5 2025, 7:36 PM
Reviewer
zlei
Differential Revision
D53545: ifconfig: Fix invalid free() in ifbridge
Parents
rG0595e10ec773: contrib/bsddialog: Import version 1.0.5
Branches
Unknown
Tags
Unknown