Page MenuHomeFreeBSD

lib: make use of reallocarray(3).
ClosedPublic

Authored by pfg on Mar 12 2017, 4:16 PM.
Tags
None
Referenced Files
F106660265: D9980.diff
Fri, Jan 3, 1:26 PM
Unknown Object (File)
Tue, Dec 17, 1:38 PM
Unknown Object (File)
Dec 1 2024, 8:24 AM
Unknown Object (File)
Nov 1 2024, 3:18 PM
Unknown Object (File)
Oct 27 2024, 8:21 AM
Unknown Object (File)
Oct 23 2024, 2:30 AM
Unknown Object (File)
Sep 27 2024, 3:41 PM
Unknown Object (File)
Sep 25 2024, 12:03 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

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

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

lib/libusbhid/usage.c
116

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

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.