From: Volker Lendecke Date: Fri, 5 Jun 2020 12:54:22 +0000 (+0200) Subject: smbclient: Do early return in do_list_helper(). X-Git-Tag: ldb-2.2.0~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d71564e07f9b5be559200d134cedfbce9c9d2c7e;p=thirdparty%2Fsamba.git smbclient: Do early return in do_list_helper(). Align integer types. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/client/client.c b/source3/client/client.c index c7ad339fa23..c423f0b8e71 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -793,60 +793,60 @@ static NTSTATUS do_list_helper(const char *mntpoint, struct file_info *f, *dir_end = '\0'; } - if (f->attr & FILE_ATTRIBUTE_DIRECTORY) { - if (do_list_dirs && do_this_one(f)) { + if (!(f->attr & FILE_ATTRIBUTE_DIRECTORY)) { + if (do_this_one(f)) { status = do_list_fn(cli_state, f, dir); - if (!NT_STATUS_IS_OK(status)) { - return status; - } } - if (do_list_recurse && - f->name && - !strequal(f->name,".") && - !strequal(f->name,"..")) { - char *mask2 = NULL; - char *p = NULL; - - if (!f->name[0]) { - d_printf("Empty dir name returned. Possible server misconfiguration.\n"); - TALLOC_FREE(dir); - return NT_STATUS_UNSUCCESSFUL; - } + TALLOC_FREE(dir); + return status; + } - mask2 = talloc_asprintf(ctx, + if (do_list_dirs && do_this_one(f)) { + status = do_list_fn(cli_state, f, dir); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + } + if (do_list_recurse && + f->name && + !strequal(f->name,".") && + !strequal(f->name,"..")) { + char *mask2 = NULL; + char *p = NULL; + + if (!f->name[0]) { + d_printf("Empty dir name returned. Possible server misconfiguration.\n"); + TALLOC_FREE(dir); + return NT_STATUS_UNSUCCESSFUL; + } + + mask2 = talloc_asprintf(ctx, "%s%s", mntpoint, mask); - if (!mask2) { - TALLOC_FREE(dir); - return NT_STATUS_NO_MEMORY; - } - p = strrchr_m(mask2,CLI_DIRSEP_CHAR); - if (p) { - p[1] = 0; - } else { - mask2[0] = '\0'; - } - mask2 = talloc_asprintf_append(mask2, - "%s%s*", - f->name, - CLI_DIRSEP_STR); - if (!mask2) { - TALLOC_FREE(dir); - return NT_STATUS_NO_MEMORY; - } - add_to_do_list_queue(mask2); - TALLOC_FREE(mask2); + if (!mask2) { + TALLOC_FREE(dir); + return NT_STATUS_NO_MEMORY; } - TALLOC_FREE(dir); - return NT_STATUS_OK; - } - - if (do_this_one(f)) { - status = do_list_fn(cli_state, f, dir); + p = strrchr_m(mask2,CLI_DIRSEP_CHAR); + if (p) { + p[1] = 0; + } else { + mask2[0] = '\0'; + } + mask2 = talloc_asprintf_append(mask2, + "%s%s*", + f->name, + CLI_DIRSEP_STR); + if (!mask2) { + TALLOC_FREE(dir); + return NT_STATUS_NO_MEMORY; + } + add_to_do_list_queue(mask2); + TALLOC_FREE(mask2); } TALLOC_FREE(dir); - return status; + return NT_STATUS_OK; } /**************************************************************************** @@ -1786,7 +1786,7 @@ static int do_allinfo(const char *name) uint16_t fnum; unsigned int num_streams; struct stream_struct *streams; - int num_snapshots; + int j, num_snapshots; char **snapshots = NULL; unsigned int i; NTSTATUS status; @@ -1894,12 +1894,12 @@ static int do_allinfo(const char *name) return 0; } - for (i=0; i