diff options
author | Swen Schillig <swen@linux.ibm.com> | 2019-08-19 13:29:03 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-08-22 00:21:50 +0000 |
commit | 968f72041021ccc0301220833f987dad8e3b9364 (patch) | |
tree | 3a9a04d139dba2d7fd03c0c4e6ec63e4977ef938 | |
parent | a7e7a62f7d3697660ba3575b94276e3a0489b57b (diff) | |
download | samba-968f72041021ccc0301220833f987dad8e3b9364.tar.gz |
s3: free popt context in utils
If done with popt context it should be free'd.
Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
-rw-r--r-- | source3/utils/dbwrap_tool.c | 1 | ||||
-rw-r--r-- | source3/utils/dbwrap_torture.c | 1 | ||||
-rw-r--r-- | source3/utils/log2pcaphex.c | 3 | ||||
-rw-r--r-- | source3/utils/mvxattr.c | 4 | ||||
-rw-r--r-- | source3/utils/ntlm_auth.c | 3 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 14 | ||||
-rw-r--r-- | source3/utils/regedit.c | 2 | ||||
-rw-r--r-- | source3/utils/sharesec.c | 16 | ||||
-rw-r--r-- | source3/utils/smbcontrol.c | 2 | ||||
-rw-r--r-- | source3/utils/smbget.c | 17 | ||||
-rw-r--r-- | source3/utils/smbtree.c | 2 | ||||
-rw-r--r-- | source3/utils/split_tokens.c | 1 | ||||
-rw-r--r-- | source3/utils/status.c | 9 |
13 files changed, 58 insertions, 17 deletions
diff --git a/source3/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c index 2808a5d68bf..84ff6f9d3c4 100644 --- a/source3/utils/dbwrap_tool.c +++ b/source3/utils/dbwrap_tool.c @@ -567,6 +567,7 @@ int main(int argc, const char **argv) } done: + poptFreeContext(pc); TALLOC_FREE(mem_ctx); return ret; } diff --git a/source3/utils/dbwrap_torture.c b/source3/utils/dbwrap_torture.c index 2f9e72720a3..f1cdc78d29e 100644 --- a/source3/utils/dbwrap_torture.c +++ b/source3/utils/dbwrap_torture.c @@ -342,6 +342,7 @@ int main(int argc, const char *argv[]) } done: + poptFreeContext(pc); talloc_free(mem_ctx); return ret; } diff --git a/source3/utils/log2pcaphex.c b/source3/utils/log2pcaphex.c index 70558ac5b8f..6a9b89f1c07 100644 --- a/source3/utils/log2pcaphex.c +++ b/source3/utils/log2pcaphex.c @@ -345,6 +345,7 @@ int main(int argc, const char **argv) in = fopen(infile, "r"); if(!in) { perror("fopen"); + poptFreeContext(pc); return 1; } } else in = stdin; @@ -356,6 +357,7 @@ int main(int argc, const char **argv) if(!out) { perror("fopen"); fprintf(stderr, "Can't find %s, using stdout...\n", outfile); + poptFreeContext(pc); return 1; } } @@ -398,5 +400,6 @@ int main(int argc, const char **argv) fclose(out); } + poptFreeContext(pc); return 0; } diff --git a/source3/utils/mvxattr.c b/source3/utils/mvxattr.c index 1275c5c07f5..d15025b800f 100644 --- a/source3/utils/mvxattr.c +++ b/source3/utils/mvxattr.c @@ -108,7 +108,7 @@ int main(int argc, const char *argv[]) { int c; const char *path = NULL; - poptContext pc; + poptContext pc = NULL; struct poptOption long_options[] = { POPT_AUTOHELP { @@ -214,9 +214,9 @@ int main(int argc, const char *argv[]) state.follow_symlink ? 0 : FTW_PHYS); } +done: poptFreeContext(pc); -done: TALLOC_FREE(frame); return ret; } diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index c02e8a70a9e..a10b3ef27f1 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -2534,6 +2534,7 @@ enum { if (argc == 1) { poptPrintHelp(pc, stderr, 0); + poptFreeContext(pc); return 1; } @@ -2674,6 +2675,7 @@ enum { if (diagnostics) { if (!diagnose_ntlm_auth()) { + poptFreeContext(pc); return 1; } } else { @@ -2681,6 +2683,7 @@ enum { fstr_sprintf(user, "%s%c%s", opt_domain, winbind_separator(), opt_username); if (!check_plaintext_auth(user, opt_password, True)) { + poptFreeContext(pc); return 1; } } diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 74f8c3b0b2f..64ae08d4f0d 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -1186,6 +1186,7 @@ int main(int argc, const char **argv) checkparms = setparms & ~MASK_ALWAYS_GOOD; if (checkparms & BIT_FIX_INIT) { + poptFreeContext(pc); return fix_users_list(); } @@ -1242,6 +1243,8 @@ int main(int argc, const char **argv) (checkparms & BIT_EXPORT)) && !(checkparms & ~(BIT_IMPORT +BIT_EXPORT +BIT_USER))) { + poptFreeContext(pc); + if (backend_in) { status = make_pdb_method_name(&bin, backend_in); } else { @@ -1299,9 +1302,11 @@ int main(int argc, const char **argv) /* list users operations */ if (checkparms & BIT_LIST) { if (!(checkparms & ~BIT_LIST)) { + poptFreeContext(pc); return print_users_list(verbose, spstyle); } if (!(checkparms & ~(BIT_USER + BIT_LIST))) { + poptFreeContext(pc); return print_user_info(user_name, verbose, spstyle); } } @@ -1326,12 +1331,14 @@ int main(int argc, const char **argv) /* check use of -u option */ if (!(checkparms & BIT_USER)) { fprintf (stderr, "Username not specified! (use -u option)\n"); + poptFreeContext(pc); return -1; } /* account creation operations */ if (!(checkparms & ~(BIT_CREATE + BIT_USER + BIT_MACHINE))) { - if (checkparms & BIT_MACHINE) { + poptFreeContext(pc); + if (checkparms & BIT_MACHINE) { return new_machine(user_name, machine_sid); } else { return new_user(user_name, full_name, @@ -1343,7 +1350,8 @@ int main(int argc, const char **argv) /* account deletion operations */ if (!(checkparms & ~(BIT_DELETE + BIT_USER + BIT_MACHINE))) { - if (checkparms & BIT_MACHINE) { + poptFreeContext(pc); + if (checkparms & BIT_MACHINE) { return delete_machine_entry(user_name); } else { return delete_user_entry(user_name); @@ -1352,6 +1360,7 @@ int main(int argc, const char **argv) /* account modification operations */ if (!(checkparms & ~(BIT_MODIFY + BIT_USER + BIT_MACHINE))) { + poptFreeContext(pc); if (checkparms & BIT_MACHINE) { return set_machine_info(user_name, account_control, @@ -1373,6 +1382,7 @@ int main(int argc, const char **argv) } poptPrintHelp(pc, stderr, 0); + poptFreeContext(pc); TALLOC_FREE(frame); return 1; } diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index 20115ae1624..2f5e0fcc1eb 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -787,6 +787,7 @@ int main(int argc, const char **argv) fprintf(stderr, "Unable to open registry: %s\n", win_errstr(rv)); TALLOC_FREE(frame); + poptFreeContext(pc); return 1; } @@ -794,6 +795,7 @@ int main(int argc, const char **argv) display_window(frame, ctx); TALLOC_FREE(frame); + poptFreeContext(pc); return 0; } diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index 2ea81b9adfa..a73af180445 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -512,16 +512,19 @@ int main(int argc, const char *argv[]) if ( !sid ) { fprintf( stderr, "Failed to retrieve Machine SID!\n"); - return 3; + retval = 3; + goto done; } printf ("%s\n", dom_sid_str_buf(sid, &buf) ); - return 0; + retval = 0; + goto done; } if ( mode == SMB_ACL_VIEW && force_acl ) { fprintf( stderr, "Invalid combination of -F and -v\n"); - return -1; + retval = -1; + goto done; } if (mode == SMB_ACL_VIEW_ALL) { @@ -547,7 +550,8 @@ int main(int argc, const char *argv[]) if(!poptPeekArg(pc)) { poptPrintUsage(pc, stderr, 0); - return -1; + retval = -1; + goto done; } fstrcpy(sharename, poptGetArg(pc)); @@ -556,7 +560,8 @@ int main(int argc, const char *argv[]) if ( snum == -1 && !force_acl ) { fprintf( stderr, "Invalid sharename: %s\n", sharename); - return -1; + retval = -1; + goto done; } switch (mode) { @@ -572,6 +577,7 @@ int main(int argc, const char *argv[]) } done: + poptFreeContext(pc); talloc_destroy(ctx); return retval; diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 1a8e59a95e2..739ee93e28b 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -1751,6 +1751,8 @@ int main(int argc, const char **argv) * shell needs 0. */ ret = !do_command(evt_ctx, msg_ctx, argc, argv); + + poptFreeContext(pc); TALLOC_FREE(frame); return ret; } diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index 58690be56e3..0b1de58ffa3 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -981,24 +981,28 @@ int main(int argc, char **argv) fprintf(stderr, "%s: %s\n", poptBadOption(pc, POPT_BADOPTION_NOALIAS), poptStrerror(c)); - return 1; + ret = 1; + goto done; } if ((opt.send_stdout || resume || opt.outputfile) && opt.update) { fprintf(stderr, "The -o, -R or -O and -U options can not be " "used together.\n"); - return 1; + ret = 1; + goto done; } if ((opt.send_stdout || opt.outputfile) && recursive) { fprintf(stderr, "The -o or -O and -R options can not be " "used together.\n"); - return 1; + ret = 1; + goto done; } if (opt.outputfile && opt.send_stdout) { fprintf(stderr, "The -o and -O options can not be " "used together.\n"); - return 1; + ret = 1; + goto done; } popt_burn_cmdline_password(argc, argv); @@ -1007,7 +1011,8 @@ int main(int argc, char **argv) if (smbc_init(get_auth_data, opt.debuglevel) < 0) { fprintf(stderr, "Unable to initialize libsmbclient\n"); - return 1; + ret= 1; + goto done; } if (smb_encrypt) { @@ -1030,6 +1035,8 @@ int main(int argc, char **argv) } } +done: + poptFreeContext(pc); TALLOC_FREE(frame); if (ret) { clean_exit(); diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 9f589b4060f..0a0dac0f9d5 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -340,11 +340,13 @@ int main(int argc, char *argv[]) /* Now do our stuff */ if (!print_tree(popt_get_cmdline_auth_info())) { + poptFreeContext(pc); TALLOC_FREE(frame); return 1; } popt_free_cmdline_auth_info(); + poptFreeContext(pc); TALLOC_FREE(frame); return 0; } diff --git a/source3/utils/split_tokens.c b/source3/utils/split_tokens.c index 98ec479ac3d..39e7396dfb3 100644 --- a/source3/utils/split_tokens.c +++ b/source3/utils/split_tokens.c @@ -68,6 +68,7 @@ int main(int argc, const char *argv[]) printf("[%s]\n", buff); } + poptFreeContext(pc); talloc_free(ctx); return 0; diff --git a/source3/utils/status.c b/source3/utils/status.c index 417c99ac6d9..b5d0b5e88c2 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -533,7 +533,7 @@ int main(int argc, const char *argv[]) bool show_processes, show_locks, show_shares; bool show_notify = false; bool resolve_uids = false; - poptContext pc; + poptContext pc = NULL; struct poptOption long_options[] = { POPT_AUTOHELP { @@ -744,11 +744,13 @@ int main(int argc, const char *argv[]) case 'P': /* Dump profile data */ ok = status_profile_dump(verbose); - return ok ? 0 : 1; + ret = ok ? 0 : 1; + goto done; case 'R': /* Continuously display rate-converted data */ ok = status_profile_rates(verbose); - return ok ? 0 : 1; + ret = ok ? 0 : 1; + goto done; default: break; } @@ -844,6 +846,7 @@ int main(int argc, const char *argv[]) } done: + poptFreeContext(pc); TALLOC_FREE(frame); return ret; } |