split a dfs path into the server, share name, and extrapath components
**********************************************************************/
-static void split_dfs_path(TALLOC_CTX *ctx,
+static bool split_dfs_path(TALLOC_CTX *ctx,
const char *nodepath,
char **pp_server,
char **pp_share,
path = talloc_strdup(ctx, nodepath);
if (!path) {
- return;
+ goto fail;
}
if ( path[0] != '\\' ) {
- return;
+ goto fail;
}
p = strchr_m( path + 1, '\\' );
if ( !p ) {
- return;
+ goto fail;
}
*p = '\0';
} else {
*pp_extrapath = talloc_strdup(ctx, "");
}
+ if (*pp_extrapath == NULL) {
+ goto fail;
+ }
*pp_share = talloc_strdup(ctx, p);
+ if (*pp_share == NULL) {
+ goto fail;
+ }
+
*pp_server = talloc_strdup(ctx, &path[1]);
+ if (*pp_server == NULL) {
+ goto fail;
+ }
+
+ TALLOC_FREE(path);
+ return true;
+
+fail:
+ TALLOC_FREE(*pp_share);
+ TALLOC_FREE(*pp_extrapath);
+ TALLOC_FREE(path);
+ return false;
}
/****************************************************************************
if (!refs[0].dfspath) {
return false;
}
- split_dfs_path(ctx, refs[0].dfspath, &server, &share, &extrapath );
-
- if (!server || !share) {
+ if (!split_dfs_path(ctx, refs[0].dfspath, &server, &share,
+ &extrapath)) {
return false;
}
return false;
}
- split_dfs_path(ctx, refs[0].dfspath, pp_newserver,
- pp_newshare, &newextrapath );
-
- if ((*pp_newserver == NULL) || (*pp_newshare == NULL)) {
+ if (!split_dfs_path(ctx, refs[0].dfspath, pp_newserver,
+ pp_newshare, &newextrapath)) {
return false;
}