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