summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-05-27 16:59:14 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-05-28 10:04:45 +0200
commit3318459fdc2df686892f4257dca709ac66784e82 (patch)
treec9e9380d9c587e702e9f4f83e37574b4ac252d91
parent892a4b24e79a71f5fd81bdb631d93615f2345bd9 (diff)
downloadsamba-3318459fdc2df686892f4257dca709ac66784e82.tar.gz
samba-3318459fdc2df686892f4257dca709ac66784e82.tar.bz2
samba-3318459fdc2df686892f4257dca709ac66784e82.zip
s4:client/client.c - fix "asprintf"s
Fix the result values or change them into "talloc_asprintf"s where possible see bug #6404
-rw-r--r--source4/client/client.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/source4/client/client.c b/source4/client/client.c
index cf834b9e1f..2a2c8ac5a3 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -863,18 +863,19 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
return;
if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)
- asprintf(&quest, "Get directory %s? ",finfo->name);
+ quest = talloc_asprintf(ctx, "Get directory %s? ",finfo->name);
else
- asprintf(&quest, "Get file %s? ",finfo->name);
+ quest = talloc_asprintf(ctx, "Get file %s? ",finfo->name);
if (ctx->prompt && !yesno(quest)) return;
- SAFE_FREE(quest);
+ talloc_free(quest);
if (!(finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)) {
- asprintf(&rname, "%s%s",ctx->remote_cur_dir,finfo->name);
+ rname = talloc_asprintf(&ctx, "%s%s",ctx->remote_cur_dir,
+ finfo->name);
do_get(ctx, rname, finfo->name, false);
- SAFE_FREE(rname);
+ talloc_free(rname);
return;
}
@@ -2832,7 +2833,7 @@ static void completion_remote_filter(struct clilist_file_info *f, const char *ma
static char **remote_completion(const char *text, int len)
{
char *dirmask;
- int i;
+ int i, ret;
completion_remote_t info;
info.samelen = len;
@@ -2855,9 +2856,14 @@ static char **remote_completion(const char *text, int len)
if (i > 0) {
info.dirmask = talloc_strndup(NULL, text, i+1);
info.dirmask[i+1] = 0;
- asprintf(&dirmask, "%s%*s*", rl_ctx->remote_cur_dir, i-1, text);
- } else
- asprintf(&dirmask, "%s*", rl_ctx->remote_cur_dir);
+ ret = asprintf(&dirmask, "%s%*s*", rl_ctx->remote_cur_dir, i-1,
+ text);
+ } else {
+ ret = asprintf(&dirmask, "%s*", rl_ctx->remote_cur_dir);
+ }
+ if (ret < 0) {
+ goto cleanup;
+ }
if (smbcli_list(rl_ctx->cli->tree, dirmask,
FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,