diff options
author | Volker Lendecke <vl@samba.org> | 2010-11-11 14:04:06 +0100 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2010-11-11 16:16:24 +0000 |
commit | 3a01edd60764723bccd742707153ab4cdf72c079 (patch) | |
tree | 7738a5ff5a65c02ed3b64b0e292cd66e3a6ed072 /source3/libsmb | |
parent | 8a22fac3a01c31732ac843f903689e42cce3a5ae (diff) | |
download | samba-3a01edd60764723bccd742707153ab4cdf72c079.tar.gz samba-3a01edd60764723bccd742707153ab4cdf72c079.tar.bz2 samba-3a01edd60764723bccd742707153ab4cdf72c079.zip |
s3: Make split_dfs_path return bool
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/clidfs.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 7e02147b8f..26c2a4a6bb 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -450,7 +450,7 @@ void cli_cm_set_credentials(struct user_auth_info *auth_info) 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, @@ -465,16 +465,16 @@ static void split_dfs_path(TALLOC_CTX *ctx, 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'; @@ -489,9 +489,28 @@ static void split_dfs_path(TALLOC_CTX *ctx, } 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; } /**************************************************************************** @@ -855,9 +874,8 @@ bool cli_resolve_path(TALLOC_CTX *ctx, 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; } @@ -1050,10 +1068,8 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx, 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; } |