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
F102653493: D42623.diff
Fri, Nov 15, 9:39 AM
Unknown Object (File)
Oct 11 2024, 9:52 PM
Unknown Object (File)
Sep 30 2024, 8:43 PM
Unknown Object (File)
Sep 27 2024, 8:49 PM
Unknown Object (File)
Sep 27 2024, 6:25 PM
Unknown Object (File)
Sep 24 2024, 9:33 PM
Unknown Object (File)
Sep 24 2024, 1:48 AM
Unknown Object (File)
Sep 23 2024, 6:31 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