@@ -625,6 +625,7 @@ FedFsStatus
nsdb_path_array_to_uri_pathname(char * const *path_array, UriUriA *uri)
{
UriPathSegmentA *pos, *result;
+ FedFsStatus status;
size_t length, len;
char *component;
unsigned int i;
@@ -641,40 +642,49 @@ nsdb_path_array_to_uri_pathname(char * const *path_array, UriUriA *uri)
if (len == 0) {
xlog(D_GENERAL, "%s: Zero-length component", __func__);
- return FEDFS_ERR_BADNAME;
+ status = FEDFS_ERR_BADNAME;
+ goto out_err;
}
if (len > NAME_MAX) {
xlog(D_GENERAL, "%s: Component length too long", __func__);
- return FEDFS_ERR_NAMETOOLONG;
+ status = FEDFS_ERR_NAMETOOLONG;
+ goto out_err;
}
if (strchr(component, '/') != NULL) {
xlog(D_GENERAL, "%s: Local separator character "
"found in component", __func__);
- return FEDFS_ERR_BADNAME;
+ status = FEDFS_ERR_BADNAME;
+ goto out_err;
}
if (!nsdb_pathname_is_utf8(component)) {
xlog(D_GENERAL, "%s: Bad character in component",
__func__);
- return FEDFS_ERR_BADCHAR;
+ status = FEDFS_ERR_BADCHAR;
+ goto out_err;
}
length += STRLEN_SLASH + len;
if (length > PATH_MAX) {
xlog(D_GENERAL, "%s: Pathname too long", __func__);
- return FEDFS_ERR_NAMETOOLONG;
+ status = FEDFS_ERR_NAMETOOLONG;
+ goto out_err;
}
pos->next = nsdb_new_uri_path_segment(component);
if (pos->next == NULL) {
- nsdb_free_path_segments(result);
- return FEDFS_ERR_SVRFAULT;
+ status = FEDFS_ERR_SVRFAULT;
+ goto out_err;
}
pos = pos->next;
}
uri->pathHead = result;
return FEDFS_OK;
+
+out_err:
+ nsdb_free_path_segments(result);
+ return status;
}
/**
Ensure that "result" is properly freed before exiting with an error. Fixes: 750fdf4bba4f5d4880ce7ad5b56451bd771cc3e2 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- src/libnsdb/path.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)