diff options
author | Kai Blin <kai@samba.org> | 2007-12-14 14:04:56 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:50:18 +0100 |
commit | 43ac3d9b44b98d44db9b1550c47e8f96a410d1e9 (patch) | |
tree | 9289d7b30bd6a0be28b4935a7314da0373e4b47c | |
parent | d8feba9faf8f135109e347b5bf5fa054df97a11a (diff) | |
download | samba-43ac3d9b44b98d44db9b1550c47e8f96a410d1e9.tar.gz samba-43ac3d9b44b98d44db9b1550c47e8f96a410d1e9.tar.bz2 samba-43ac3d9b44b98d44db9b1550c47e8f96a410d1e9.zip |
r26453: Janitorial: Don't use a static char[] in smb_readline_replacement.
Fix up callers to free the memory returned, as that is needed if we use the
original readline function as well.
(This used to be commit c81ead1c38f417d442157b21d0d389f6a540c6f9)
-rw-r--r-- | source4/client/client.c | 8 | ||||
-rw-r--r-- | source4/lib/registry/tools/regshell.c | 6 | ||||
-rw-r--r-- | source4/lib/smbreadline/smbreadline.c | 9 | ||||
-rw-r--r-- | source4/torture/rpc/samr.c | 1 | ||||
-rw-r--r-- | source4/torture/smbtorture.c | 1 |
5 files changed, 19 insertions, 6 deletions
diff --git a/source4/client/client.c b/source4/client/client.c index 748ee2d7cb..65bcfeefb6 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -2997,16 +2997,18 @@ static int process_stdin(struct smbclient_context *ctx) char *the_prompt = talloc_asprintf(ctx, "smb: %s> ", ctx->remote_cur_dir); char *cline = smb_readline(the_prompt, readline_callback, completion_fn); talloc_free(the_prompt); - + if (!cline) break; - + /* special case - first char is ! */ if (*cline == '!') { system(cline + 1); continue; } - rc |= process_command_string(ctx, cline); + rc |= process_command_string(ctx, cline); + free(cline); + } return rc; diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 1c5157e937..329d6ab670 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -546,12 +546,16 @@ int main(int argc, char **argv) via readline :-( */ line = smb_readline(prompt, NULL, reg_completion); - if (line == NULL) + if (line == NULL) { + free(prompt); break; + } if (line[0] != '\n') { ret = W_ERROR_IS_OK(process_cmd(ctx, line)); } + free(line); + free(prompt); } talloc_free(ctx); diff --git a/source4/lib/smbreadline/smbreadline.c b/source4/lib/smbreadline/smbreadline.c index e5cc3522e9..a85f335b8a 100644 --- a/source4/lib/smbreadline/smbreadline.c +++ b/source4/lib/smbreadline/smbreadline.c @@ -77,13 +77,18 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) char **(completion_fn)(const char *text, int start, int end)) { fd_set fds; - static char line[1024]; + char *line; struct timeval timeout; int fd = STDIN_FILENO; char *ret; do_debug("%s", prompt); + line = (char *)malloc(BUFSIZ); + if (!line) { + return NULL; + } + while (1) { timeout.tv_sec = 5; timeout.tv_usec = 0; @@ -92,7 +97,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) FD_SET(fd,&fds); if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) { - ret = x_fgets(line, sizeof(line), x_stdin); + ret = x_fgets(line, BUFSIZ, x_stdin); return ret; } if (callback) diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index f8d5b7030c..9d6c73891b 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -824,6 +824,7 @@ static bool test_SetAliasInfo(struct dcerpc_pipe *p, struct torture_context *tct case ALIASINFONAME: init_lsa_String(&r.in.info->name,TEST_ALIASNAME); break; case ALIASINFODESCRIPTION: init_lsa_String(&r.in.info->description, "Test Description, should test I18N as well"); break; + case ALIASINFOALL: printf("ALIASINFOALL ignored\n"); break; } status = dcerpc_samr_SetAliasInfo(p, tctx, &r); diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 6d97e9ad9d..371ddc7297 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -500,6 +500,7 @@ void run_shell(struct torture_context *tctx) run_test(tctx, argv[1]); } } + free(cline); } } |