[PATCH] Make zero size allocation result consistent

Joel Sherrill joel at rtems.org
Tue May 4 12:52:16 UTC 2021


On Tue, May 4, 2021, 7:12 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> On 04/05/2021 14:07, Joel Sherrill wrote:
> > This is undefined behaviour and I would rather they all return NULL.
>
> As far as I understood the POSIX text, it is implementation-defined
> behaviour and POSIX gives two valid implementation options. The patch
> removed some code (less code is always good) and now we are in line with
> Linux and FreeBSD.
>

We should be more focused on correctness. We don't agree with not checking
null pointers as arguments either.

If the application uses the memory returned, there is no guarantee on the
size and this leads quite naturally to a buffer overflow.

>
> > No
> > portable program should ever do this.
>
> Yes.
>
> > In fact, it should be something caught in debug mode.
>
> RTEMS_DEBUG is for RTEMS internal bugs.
>
> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.huber at embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax:   +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210504/2a6c8d69/attachment.html>


More information about the devel mailing list