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
Unknown Object (File)
Fri, Mar 6, 12:29 PM
Unknown Object (File)
Wed, Mar 4, 5:27 AM
Unknown Object (File)
Fri, Feb 27, 1:15 AM
Unknown Object (File)
Sat, Feb 21, 8:00 PM
Unknown Object (File)
Fri, Feb 20, 2:01 AM
Unknown Object (File)
Mon, Feb 16, 11:49 AM
Unknown Object (File)
Feb 8 2026, 7:12 AM
Unknown Object (File)
Feb 8 2026, 3:35 AM
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