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
F87305436: D42623.id130158.diff
Mon, Jul 1, 1:35 PM
F87304691: D42623.id130188.diff
Mon, Jul 1, 1:22 PM
Unknown Object (File)
Sat, Jun 29, 9:57 AM
Unknown Object (File)
Thu, Jun 27, 3:40 AM
Unknown Object (File)
Mar 1 2024, 8:04 AM
Unknown Object (File)
Jan 3 2024, 8:47 PM
Unknown Object (File)
Dec 23 2023, 3:07 AM
Unknown Object (File)
Dec 12 2023, 10:47 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 54461
Build 51351: arc lint + arc unit