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)
May 23 2024, 12:17 AM
Unknown Object (File)
May 22 2024, 2:39 AM
Unknown Object (File)
Apr 27 2024, 11:51 PM
Unknown Object (File)
Apr 26 2024, 5:47 PM
Unknown Object (File)
Apr 26 2024, 12:32 PM
Unknown Object (File)
Mar 22 2024, 10:27 PM
Unknown Object (File)
Mar 22 2024, 10:24 PM
Unknown Object (File)
Mar 22 2024, 10:24 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.