[SSSD] [PATCH] path_utils: path_concat should return empty string on ENOBUFS

Sumit Bose sbose at redhat.com
Wed Mar 7 15:23:49 UTC 2012


On Wed, Mar 07, 2012 at 10:08:29AM -0500, Stephen Gallagher wrote:
> This patch makes several changes.
> 
> 1) Change the behavior of path_concat so that it will always return an
> empty string if it hits ENOBUFS.
> 2) Clean up the code, adding more comments.
> 3) Modify the unit tests to check for empty string and to make sure we
> don't write past the allowed buffer if the input strings are too long.
> 4) Update the doxygen for path_concat so that it's clear that path will
> be empty on failure.

>  
> -    if (!path || path_size < 1) return ENOBUFS;
> +    if (!path || path_size < 1) {
> +        ret = ENOBUFS;
> +    }
>  

You just return with ENOBUFS here, because nothing else can be done.
Please add unit test where path is NULL and path_size is zero to check
the (small) path as well.

bye,
Sumit



More information about the sssd-devel mailing list