Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001218 [1003.1(2013)/Issue7+TC1] System Interfaces Editorial Enhancement Request 2018-12-08 21:03 2018-12-09 02:09
Reporter alanc View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Alan Coopersmith
Organization Oracle Solaris Engineering
User Reference
Section reallocarray
Page Number (page or range of pages)
Line Number (Line or range of lines)
Interp Status ---
Final Accepted Text
Summary 0001218: Add reallocarray()
Description OpenBSD created a reallocarray() function to offer overflow checking for array size calculations in the library instead of every caller:

https://man.openbsd.org/reallocarray [^] defines it as:

  void *reallocarray(void *ptr, size_t nmemb, size_t size);

  Designed for safe allocation of arrays, the reallocarray() function is
  similar to realloc() except it operates on /nmemb/ members of size /size/
  and checks for integer overflow in the calculation /nmemb/ * /size/.

Other platforms have since adopted it, including GNU libc in version 2.26.
Desired Action Add reallocarray() interface in the next edition of the standards.
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0004175)
schwarze (reporter)
2018-12-09 02:09

Here is the authoritative manual page:

  http://man.openbsd.org/reallocarray.3 [^]


Supplementary information about systems already implementing this interface:

FreeBSD provides it for three years now:
https://svnweb.freebsd.org/base/head/lib/libc/stdlib/reallocarray.c [^]

NetBSD also provides it for three years:
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdlib/reallocarray.c [^]

illumos provides it since last year:
http://src.illumos.org/source/history/illumos-gate/usr/src/lib/libc/port/gen/reallocarray.c [^]

The NetBSD implementation suffers from hiding it behind _OPENBSD_SOURCE even though it is no longer OpenBSD-specific for quite some time now. That sometimes causes issues in build systems like automatic configuration tests not finding it with subsequent symbol clashes between the libc symbol and a replacement implementation that the build system included. Including the function in the standard might convince NetBSD to no longer hide their implementation, making life easier for people who try to design portable build systems.

- Issue History
Date Modified Username Field Change
2018-12-08 21:03 alanc New Issue
2018-12-08 21:03 alanc Name => Alan Coopersmith
2018-12-08 21:03 alanc Organization => Oracle Solaris Engineering
2018-12-08 21:03 alanc Section => reallocarray
2018-12-08 21:03 alanc Page Number => (page or range of pages)
2018-12-08 21:03 alanc Line Number => (Line or range of lines)
2018-12-09 02:09 schwarze Note Added: 0004175


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker