[RFC PATCH] data_blob_realloc() accept 0 length argument

Timur I. Bakeyev timur at freebsd.org
Fri Feb 16 02:24:55 UTC 2018

Hi all!

I was debugging one of our VFS modules and figured out that the code fails
when data_blob_realloc() receives a 0 as a length argument. For me, passing
0, although seems to be useless, but still a valid invocation of the

Apparently, guys from the SSSD team also think so

What do you think about similar fix for the data_blob_talloc()?

With regards,
Timur Bakeyev.
-------------- next part --------------
--- data_blob.c.orig	2018-02-16 03:10:52.382226000 +0100
+++ data_blob.c	2018-02-16 03:14:21.640659000 +0100
@@ -213,7 +213,7 @@ _PUBLIC_ DATA_BLOB data_blob_const(const
 _PUBLIC_ bool data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length)
 	blob->data = talloc_realloc(mem_ctx, blob->data, uint8_t, length);
-	if (blob->data == NULL)
+	if (blob->data == NULL && length)
 		return false;
 	blob->length = length;
 	return true;

More information about the samba-technical mailing list