Page MenuHomeFreeBSD

pkg: Allocate a suitably-sized string for the local ABI
ClosedPublic

Authored by jhb on Nov 15 2023, 6:37 PM.
Tags
None
Referenced Files
F144408506: D42623.id130158.diff
Sun, Feb 8, 7:12 AM
F144379068: D42623.id130188.diff
Sun, Feb 8, 3:35 AM
Unknown Object (File)
Sat, Jan 31, 2:27 PM
Unknown Object (File)
Thu, Jan 22, 4:01 AM
Unknown Object (File)
Wed, Jan 21, 4:35 PM
Unknown Object (File)
Dec 11 2025, 8:31 AM
Unknown Object (File)
Dec 6 2025, 6:07 AM
Unknown Object (File)
Dec 1 2025, 10:38 PM
Subscribers

Details

Summary

Previously the local ABI string was written to an on-stack buffer and
the pointer to that buffer was saved in a global before the function
returned. This had two issues: c[ABI].val pointed to a
no-longer-valid on-stack buffer after config_init returned, and the
string could potentially be truncated. Fix both of those by changing
pkg_get_myabi to return a pointer to a string allocated by asprintf.

Reported by: GCC 13 -Wdangling-pointer

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable