s3: free popt context in utils
authorSwen Schillig <swen@linux.ibm.com>
Mon, 19 Aug 2019 11:29:03 +0000 (13:29 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 22 Aug 2019 00:21:50 +0000 (00:21 +0000)
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>
13 files changed:
source3/utils/dbwrap_tool.c
source3/utils/dbwrap_torture.c
source3/utils/log2pcaphex.c
source3/utils/mvxattr.c
source3/utils/ntlm_auth.c
source3/utils/pdbedit.c
source3/utils/regedit.c
source3/utils/sharesec.c
source3/utils/smbcontrol.c
source3/utils/smbget.c
source3/utils/smbtree.c
source3/utils/split_tokens.c
source3/utils/status.c

index 2808a5d68bfe5754fb1fa2f4683792c7228633a8..84ff6f9d3c465c9311154eb0607ff2cf9cc95adc 100644 (file)
@@ -567,6 +567,7 @@ int main(int argc, const char **argv)
        }
 
 done:
+       poptFreeContext(pc);
        TALLOC_FREE(mem_ctx);
        return ret;
 }
index 2f9e72720a3c79d45568cce5826995fd646b2c58..f1cdc78d29eb7fed4b0b1280fcea6523d9b93faa 100644 (file)
@@ -342,6 +342,7 @@ int main(int argc, const char *argv[])
        }
 
 done:
+       poptFreeContext(pc);
        talloc_free(mem_ctx);
        return ret;
 }
index 70558ac5b8f8743ca029a39b03c2369e7466451c..6a9b89f1c07d82206cbf1b6fcae661ccf4a43c27 100644 (file)
@@ -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;
 }
index 1275c5c07f5e1ab9aa397813db166a265d940069..d15025b800f2fc6cc40fa84c977f90f7436b2492 100644 (file)
@@ -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;
 }
index c02e8a70a9e04e4a4d03f5e3d539b8a9ccf929fb..a10b3ef27f16e84e488ee00372fc25f782a67b48 100644 (file)
@@ -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;
                }
        }
index 74f8c3b0b2f6598957ac11936a9e9631b18f635a..64ae08d4f0d5b293b4709c56ab380b50de6badbb 100644 (file)
@@ -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;
 }
index 20115ae16243c2460b473e59e9d53de9230f1cec..2f5e0fcc1eb1c0975254e6529a89628b5745610e 100644 (file)
@@ -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;
 }
index 2ea81b9adfae977d844d2a7db308a9de270980bb..a73af18044515edbdd5a83e1970b3c11c2c44d4d 100644 (file)
@@ -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;
index 1a8e59a95e2095ca653ae72e51a3fac65f7da675..739ee93e28bfd3d582768ea114fb91e19d853288 100644 (file)
@@ -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;
 }
index 58690be56e35b18771aeac0f83a3185ebc135d90..0b1de58ffa39641605b510b5afd1aa5f7e8811d3 100644 (file)
@@ -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();
index 9f589b4060f2e22c4207da2aebda05297f9978d5..0a0dac0f9d5deffb75d05a0eee87facce63002ee 100644 (file)
@@ -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;
 }
index 98ec479ac3d9fbb9d6bb441d7c48f99968f4a9db..39e7396dfb3688295c6450cd7469f5ca595a5b1d 100644 (file)
@@ -68,6 +68,7 @@ int main(int argc, const char *argv[])
                printf("[%s]\n", buff);
        }
 
+       poptFreeContext(pc);
        talloc_free(ctx);
 
        return 0;
index 417c99ac6d9191ae0bf2f663b2415e54b403153f..b5d0b5e88c224d899da41a710145d8323498c3ef 100644 (file)
@@ -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;
 }