Page MenuHomeFreeBSD

lib: make use of reallocarray(3).
ClosedPublic

Authored by pfg on Mar 12 2017, 4:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 6, 2:26 AM
Unknown Object (File)
Wed, Sep 17, 8:11 PM
Unknown Object (File)
Sep 5 2025, 8:12 AM
Unknown Object (File)
Aug 30 2025, 10:59 PM
Unknown Object (File)
Aug 22 2025, 4:14 AM
Unknown Object (File)
Aug 15 2025, 6:17 AM
Unknown Object (File)
Aug 10 2025, 3:17 AM
Unknown Object (File)
Jul 23 2025, 3:33 PM
Subscribers

Details

Summary

Use reallocarray(3) when reallocation involves a multiplication.
AFAICT, these libraries that are not meant to be portable so
reallocarray(3) is not a maintainance concern.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Minor enhancement in libthread_db, move a multiplier to the second
argument to reduce risk of an overflow in the first argument.

I'm ok with the non-contributed source code being adapted to the new pattern (sidenote: I'm a bit sad that these libraries aren't in contrib/)..

lib/libiconv_modules/ISO2022/citrus_iso2022.c
262–263 ↗(On Diff #26191)

I would leave this hunk alone since it's citrus iconv is shared between FreeBSD and IllumOS.

lib/libusbhid/usage.c
116 ↗(On Diff #26191)

This code came from NetBSD. I'd probably leave it alone.

This revision is now accepted and ready to land.Apr 18 2017, 1:28 AM
pfg planned changes to this revision.Apr 18 2017, 1:43 AM

TBH, I am wondering the usefulness fo these replacements.
It is not clear if overflows are possible at all. OTOH I am pretty sure the changes won't hurt.

lib/libiconv_modules/ISO2022/citrus_iso2022.c
262–263 ↗(On Diff #26191)

This comes from NetBSD/citrus. Illumos has it because we are their upstream for this, and illumos will be adopting reallocarray(3) as well.

pfg edited edge metadata.

Updated version: drop some cases where overflows are very unlikely.

This revision was automatically updated to reflect the committed changes.