Re: svn commit: r352421 - head/stand/libsa

2019-09-17 Thread Konstantin Belousov
On Tue, Sep 17, 2019 at 12:05:26PM +0300, Toomas Soome wrote:
> 
> 
> > On 17 Sep 2019, at 11:56, Konstantin Belousov  wrote:
> > 
> > On Mon, Sep 16, 2019 at 08:28:09PM +, Toomas Soome wrote:
> >> Author: tsoome
> >> Date: Mon Sep 16 20:28:08 2019
> >> New Revision: 352421
> >> URL: https://svnweb.freebsd.org/changeset/base/352421
> >> 
> >> Log:
> >>  loader: Malloc(0) should return NULL.
> >> 
> >>  We really should not allocate anything with size 0.
> > Why ?  This is quite unexpected from other environments, where
> > malloc(0) returns unique object.
> > 
> 
> Hiding bugs. And, we are not getting unique object, we are getting chunk of 
> memory with payload length of 0 and the memory content depends on if head and 
> tail guards are used - the chunk is with size at least MALLOCALIGN (16 or 64 
> bytes) and the chunk is from random location of heap.
> 

Yes, exactly, this is how all other mallocs behave.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r352421 - head/stand/libsa

2019-09-17 Thread Toomas Soome via svn-src-all



> On 17 Sep 2019, at 11:56, Konstantin Belousov  wrote:
> 
> On Mon, Sep 16, 2019 at 08:28:09PM +, Toomas Soome wrote:
>> Author: tsoome
>> Date: Mon Sep 16 20:28:08 2019
>> New Revision: 352421
>> URL: https://svnweb.freebsd.org/changeset/base/352421
>> 
>> Log:
>>  loader: Malloc(0) should return NULL.
>> 
>>  We really should not allocate anything with size 0.
> Why ?  This is quite unexpected from other environments, where
> malloc(0) returns unique object.
> 

Hiding bugs. And, we are not getting unique object, we are getting chunk of 
memory with payload length of 0 and the memory content depends on if head and 
tail guards are used - the chunk is with size at least MALLOCALIGN (16 or 64 
bytes) and the chunk is from random location of heap.

rgds,
toomas
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r352421 - head/stand/libsa

2019-09-17 Thread Konstantin Belousov
On Mon, Sep 16, 2019 at 08:28:09PM +, Toomas Soome wrote:
> Author: tsoome
> Date: Mon Sep 16 20:28:08 2019
> New Revision: 352421
> URL: https://svnweb.freebsd.org/changeset/base/352421
> 
> Log:
>   loader: Malloc(0) should return NULL.
>   
>   We really should not allocate anything with size 0.
Why ?  This is quite unexpected from other environments, where
malloc(0) returns unique object.

> 
> Modified:
>   head/stand/libsa/zalloc_malloc.c
> 
> Modified: head/stand/libsa/zalloc_malloc.c
> ==
> --- head/stand/libsa/zalloc_malloc.c  Mon Sep 16 20:26:53 2019
> (r352420)
> +++ head/stand/libsa/zalloc_malloc.c  Mon Sep 16 20:28:08 2019
> (r352421)
> @@ -55,6 +55,9 @@ Malloc(size_t bytes, const char *file, int line)
>  {
>  Guard *res;
>  
> +if (bytes == 0)
> + return (NULL);
> +
>  #ifdef USEENDGUARD
>  bytes += MALLOCALIGN + 1;
>  #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352421 - head/stand/libsa

2019-09-16 Thread Toomas Soome
Author: tsoome
Date: Mon Sep 16 20:28:08 2019
New Revision: 352421
URL: https://svnweb.freebsd.org/changeset/base/352421

Log:
  loader: Malloc(0) should return NULL.
  
  We really should not allocate anything with size 0.

Modified:
  head/stand/libsa/zalloc_malloc.c

Modified: head/stand/libsa/zalloc_malloc.c
==
--- head/stand/libsa/zalloc_malloc.cMon Sep 16 20:26:53 2019
(r352420)
+++ head/stand/libsa/zalloc_malloc.cMon Sep 16 20:28:08 2019
(r352421)
@@ -55,6 +55,9 @@ Malloc(size_t bytes, const char *file, int line)
 {
 Guard *res;
 
+if (bytes == 0)
+   return (NULL);
+
 #ifdef USEENDGUARD
 bytes += MALLOCALIGN + 1;
 #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"