Jeremy.
/* Ensure cur_dir ends in a DIRSEP */
if ((new_cd[0] != '\0') && (*(new_cd+strlen(new_cd)-1) != CLI_DIRSEP_CHAR)) {
- new_cd = talloc_asprintf_append(new_cd, CLI_DIRSEP_STR);
+ new_cd = talloc_asprintf_append(new_cd, "%s", CLI_DIRSEP_STR);
if (!new_cd) {
goto out;
}
if (*buf == CLI_DIRSEP_CHAR) {
mask = talloc_strdup(ctx, buf);
} else {
- mask = talloc_asprintf_append(mask, buf);
+ mask = talloc_asprintf_append(mask, "%s", buf);
}
} else {
mask = talloc_asprintf_append(mask, "*");
return 1;
}
if ((mask[0] != '\0') && (mask[strlen(mask)-1]!=CLI_DIRSEP_CHAR)) {
- mask = talloc_asprintf_append(mask, CLI_DIRSEP_STR);
+ mask = talloc_asprintf_append(mask, "%s", CLI_DIRSEP_STR);
if (!mask) {
return 1;
}
if (*buf == CLI_DIRSEP_CHAR) {
mask = talloc_strdup(ctx, buf);
} else {
- mask = talloc_asprintf_append(mask, buf);
+ mask = talloc_asprintf_append(mask, "%s", buf);
}
} else {
mask = talloc_strdup(ctx, "*");
d_printf("get <filename> [localname]\n");
return 1;
}
- rname = talloc_asprintf_append(rname, fname);
+ rname = talloc_asprintf_append(rname, "%s", fname);
if (!rname) {
return 1;
}
}
do_list(mget_mask, aSYSTEM | aHIDDEN | aDIR,do_mget,false, true);
- chdir("..");
+ if (chdir("..") == -1) {
+ d_printf("do_mget: failed to chdir to .. (error %s)\n",
+ strerror(errno) );
+ }
client_set_cur_dir(saved_curdir);
TALLOC_FREE(mget_mask);
TALLOC_FREE(saved_curdir);
unlink(lname);
return 1;
}
- rname = talloc_asprintf_append(rname, fname);
+ rname = talloc_asprintf_append(rname, "%s", fname);
if (!rname) {
return 1;
}
if (!pager_cmd) {
return 1;
}
- system(pager_cmd);
+ if (system(pager_cmd) == -1) {
+ d_printf("system command '%s' returned -1\n",
+ pager_cmd);
+ }
unlink(lname);
return rc;
mget_mask = talloc_strdup(ctx, buf);
} else {
mget_mask = talloc_asprintf_append(mget_mask,
- buf);
+ "%s", buf);
}
if (!mget_mask) {
return 1;
}
return 1;
}
- mask = talloc_asprintf_append(mask, buf);
+ mask = talloc_asprintf_append(mask, "%s", buf);
if (!mask) {
return 1;
}
trim_char(ddir,'.','\0');
p = strtok_r(ddir, "/\\", &saveptr);
while (p) {
- ddir2 = talloc_asprintf_append(ddir2, p);
+ ddir2 = talloc_asprintf_append(ddir2, "%s", p);
if (!ddir2) {
return 1;
}
if (!cli_chkpath(targetcli, ddir2)) {
do_mkdir(ddir2);
}
- ddir2 = talloc_asprintf_append(ddir2, CLI_DIRSEP_STR);
+ ddir2 = talloc_asprintf_append(ddir2, "%s", CLI_DIRSEP_STR);
if (!ddir2) {
return 1;
}
d_printf("altname <file>\n");
return 1;
}
- name = talloc_asprintf_append(name, buf);
+ name = talloc_asprintf_append(name, "%s", buf);
if (!name) {
return 1;
}
d_printf("allinfo <file>\n");
return 1;
}
- name = talloc_asprintf_append(name, buf);
+ name = talloc_asprintf_append(name, "%s", buf);
if (!name) {
return 1;
}
}
if (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
- rname = talloc_asprintf_append(rname, buf);
+ rname = talloc_asprintf_append(rname, "%s", buf);
} else {
- rname = talloc_asprintf_append(rname, lname);
+ rname = talloc_asprintf_append(rname, "%s", lname);
}
if (!rname) {
return 1;
d_printf("del <filename>\n");
return 1;
}
- mask = talloc_asprintf_append(mask, buf);
+ mask = talloc_asprintf_append(mask, "%s", buf);
if (!mask) {
return 1;
}
char *d;
if (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
- chdir(buf);
+ if (chdir(buf) == -1) {
+ d_printf("chdir to %s failed (%s)\n",
+ buf, strerror(errno));
+ }
}
d = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
if (!d) {
d_printf("reget <filename>\n");
return 1;
}
- remote_name = talloc_asprintf_append(remote_name, fname);
+ remote_name = talloc_asprintf_append(remote_name, "%s", fname);
if (!remote_name) {
return 1;
}
if (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) {
remote_name = talloc_asprintf_append(remote_name,
- buf);
+ "%s", buf);
} else {
remote_name = talloc_asprintf_append(remote_name,
- local_name);
+ "%s", local_name);
}
if (!remote_name) {
return 1;
TALLOC_FREE(ctx);
return;
}
- tmp = talloc_asprintf_append(tmp, f->name);
+ tmp = talloc_asprintf_append(tmp, "%s", f->name);
if (!tmp) {
TALLOC_FREE(ctx);
return;
}
if (f->mode & aDIR) {
- tmp = talloc_asprintf_append(tmp, CLI_DIRSEP_STR);
+ tmp = talloc_asprintf_append(tmp, "%s", CLI_DIRSEP_STR);
}
if (!tmp) {
TALLOC_FREE(ctx);
/* special case - first char is ! */
if (*line == '!') {
- system(line + 1);
+ if (system(line + 1) == -1) {
+ d_printf("system() command %s failed.\n",
+ line+1);
+ }
SAFE_FREE(line);
TALLOC_FREE(frame);
continue;
*err_str = NULL;
if(!resolve_name( remote_machine, &ss, 0x20)) {
- asprintf(err_str, "Unable to find an IP address for machine "
- "%s.\n", remote_machine);
+ if (asprintf(err_str, "Unable to find an IP address for machine "
+ "%s.\n", remote_machine) == -1) {
+ *err_str = NULL;
+ }
return NT_STATUS_UNSUCCESSFUL;
}
result = cli_connect(cli, remote_machine, &ss);
if (!NT_STATUS_IS_OK(result)) {
- asprintf(err_str, "Unable to connect to SMB server on "
+ if (asprintf(err_str, "Unable to connect to SMB server on "
"machine %s. Error was : %s.\n",
- remote_machine, nt_errstr(result));
+ remote_machine, nt_errstr(result))==-1) {
+ *err_str = NULL;
+ }
cli_shutdown(cli);
return result;
}
make_nmb_name(&called , remote_machine, 0x20);
if (!cli_session_request(cli, &calling, &called)) {
- asprintf(err_str, "machine %s rejected the session setup. "
+ if (asprintf(err_str, "machine %s rejected the session setup. "
"Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
+ remote_machine, cli_errstr(cli)) == -1) {
+ *err_str = NULL;
+ }
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
result = cli_negprot(cli);
if (!NT_STATUS_IS_OK(result)) {
- asprintf(err_str, "machine %s rejected the negotiate "
+ if (asprintf(err_str, "machine %s rejected the negotiate "
"protocol. Error was : %s.\n",
- remote_machine, nt_errstr(result));
+ remote_machine, nt_errstr(result)) == -1) {
+ *err_str = NULL;
+ }
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
if (!NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_MUST_CHANGE) &&
!NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_EXPIRED)) {
- asprintf(err_str, "Could not connect to machine %s: "
- "%s\n", remote_machine, cli_errstr(cli));
+ if (asprintf(err_str, "Could not connect to machine %s: "
+ "%s\n", remote_machine, cli_errstr(cli)) == -1) {
+ *err_str = NULL;
+ }
cli_shutdown(cli);
return result;
}
result = cli_session_setup(cli, "", "", 0, "", 0, "");
if (!NT_STATUS_IS_OK(result)) {
- asprintf(err_str, "machine %s rejected the session "
+ if (asprintf(err_str, "machine %s rejected the session "
"setup. Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
+ remote_machine, cli_errstr(cli)) == -1) {
+ *err_str = NULL;
+ }
cli_shutdown(cli);
return result;
}
}
if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) {
- asprintf(err_str, "machine %s rejected the tconX on the IPC$ "
+ if (asprintf(err_str, "machine %s rejected the tconX on the IPC$ "
"share. Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
+ remote_machine, cli_errstr(cli)) == -1) {
+ *err_str = NULL;
+ }
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
if (lp_client_lanman_auth()) {
/* Use the old RAP method. */
if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) {
- asprintf(err_str, "machine %s rejected the "
+ if (asprintf(err_str, "machine %s rejected the "
"password change: Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
+ remote_machine, cli_errstr(cli)) == -1) {
+ *err_str = NULL;
+ }
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
}
} else {
- asprintf(err_str, "SAMR connection to machine %s "
+ if (asprintf(err_str, "SAMR connection to machine %s "
"failed. Error was %s, but LANMAN password "
"changed are disabled\n",
- nt_errstr(result), remote_machine);
+ nt_errstr(result), remote_machine) == -1) {
+ *err_str = NULL;
+ }
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
|| NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))) {
/* it failed, but for reasons such as wrong password, too short etc ... */
- asprintf(err_str, "machine %s rejected the password change: "
+ if (asprintf(err_str, "machine %s rejected the password change: "
"Error was : %s.\n",
- remote_machine, get_friendly_nt_error_msg(result));
+ remote_machine, get_friendly_nt_error_msg(result)) == -1) {
+ *err_str = NULL;
+ }
cli_shutdown(cli);
return result;
}
|| NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))) {
/* it failed, but again it was due to things like new password too short */
- asprintf(err_str, "machine %s rejected the "
+ if (asprintf(err_str, "machine %s rejected the "
"(anonymous) password change: Error was : "
"%s.\n", remote_machine,
- get_friendly_nt_error_msg(result));
+ get_friendly_nt_error_msg(result)) == -1) {
+ *err_str = NULL;
+ }
cli_shutdown(cli);
return result;
}
cli_shutdown(cli);
return NT_STATUS_OK;
}
- asprintf(err_str, "machine %s rejected the password "
+ if (asprintf(err_str, "machine %s rejected the password "
"change: Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
+ remote_machine, cli_errstr(cli)) == -1) {
+ *err_str = NULL;
+ }
result = cli_nt_error(cli);
cli_shutdown(cli);
return result;
} else {
- asprintf(err_str, "SAMR connection to machine %s "
+ if (asprintf(err_str, "SAMR connection to machine %s "
"failed. Error was %s, but LANMAN password "
"changed are disabled\n",
- nt_errstr(result), remote_machine);
+ nt_errstr(result), remote_machine) == -1) {
+ *err_str = NULL;
+ }
cli_shutdown(cli);
return NT_STATUS_UNSUCCESSFUL;
}
print "#include \"build_env.h\"";
print "#include \"dynconfig.h\"";
print "";
- print "static void output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
+ print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
print "void build_options(bool screen);";
print "";
print "";
print "/****************************************************************************";
print "helper function for build_options";
print "****************************************************************************/";
- print "static void output(bool screen, const char *format, ...)";
+ print "static int output(bool screen, const char *format, ...)";
print "{";
- print " char *ptr;";
+ print " char *ptr = NULL;";
+ print " int ret = 0;";
print " va_list ap;";
print " ";
print " va_start(ap, format);";
- print " vasprintf(&ptr,format,ap);";
+ print " ret = vasprintf(&ptr,format,ap);";
print " va_end(ap);";
print "";
print " if (screen) {";
- print " d_printf(\"%s\", ptr);";
+ print " d_printf(\"%s\", ptr ? ptr : \"\");";
print " } else {";
- print " DEBUG(4,(\"%s\", ptr));";
+ print " DEBUG(4,(\"%s\", ptr ? ptr : \"\"));";
print " }";
print " ";
print " SAFE_FREE(ptr);";
+ print " return ret;";
print "}";
print "";
print "/****************************************************************************";
}
sidstr = sid_binstring(sid);
- asprintf(&ldap_exp, "(objectSid=%s)", sidstr);
+ if (asprintf(&ldap_exp, "(objectSid=%s)", sidstr) == -1) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
rc = ads_search_retry(ads, &msg, ldap_exp, attrs);
free(ldap_exp);
free(sidstr);
}
- asprintf( &keystr, "TRUSTDOMCACHE/%s", domain_name );
+ if (asprintf( &keystr, "TRUSTDOMCACHE/%s", domain_name ) == -1) {
+ return key;
+ }
key = string_term_tdb_data(keystr);
return key;