1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

fixes (asprintf) from 2.2

(This used to be commit 6b123adda9)
This commit is contained in:
Simo Sorce 2002-01-19 17:29:32 +00:00
parent 72544acc0d
commit 7019bfe546
5 changed files with 24 additions and 17 deletions

View File

@ -1343,7 +1343,7 @@ static int cmd_mput(void)
/* if (!recurse) continue; */
SAFE_FREE(quest);
asprintf(&quest, "Put directory %s? ", lname);
if (asprintf(&quest, "Put directory %s? ", lname) < 0) break;
if (prompt && !yesno(quest)) { /* No */
/* Skip the directory */
lname[strlen(lname)-1] = '/';
@ -1351,7 +1351,7 @@ static int cmd_mput(void)
break;
} else { /* Yes */
SAFE_FREE(rname);
asprintf(&rname, "%s%s", cur_dir, lname);
if(asprintf(&rname, "%s%s", cur_dir, lname) < 0) break;
dos_format(rname);
if (!cli_chkpath(cli, rname) &&
!do_mkdir(rname)) {
@ -1365,13 +1365,13 @@ static int cmd_mput(void)
continue;
} else {
SAFE_FREE(quest);
asprintf(&quest,"Put file %s? ", lname);
if (asprintf(&quest,"Put file %s? ", lname) < 0) break;
if (prompt && !yesno(quest)) /* No */
continue;
/* Yes */
SAFE_FREE(rname);
asprintf(&rname, "%s%s", cur_dir, lname);
if (asprintf(&rname, "%s%s", cur_dir, lname) < 0) break;
}
dos_format(rname);

View File

@ -803,6 +803,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
va_list ap;
int ret;
*ptr = NULL;
va_start(ap, format);
ret = vasprintf(ptr, format, ap);
va_end(ap);

View File

@ -712,10 +712,12 @@ static void dump_conn_list(void)
/* Display pipe info */
asprintf(&msg, "\t%-15s %-15s %-16s", con->domain, con->controller, con->pipe_name);
DEBUG(0, ("%s\n", msg));
free(msg);
if (asprintf(&msg, "\t%-15s %-15s %-16s", con->domain, con->controller, con->pipe_name) < 0) {
DEBUG(0, ("Error: not enough memory!\n"));
} else {
DEBUG(0, ("%s\n", msg));
SAFE_FREE(msg);
}
}
}

View File

@ -488,13 +488,13 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user)
sam_user = pdb_get_username(user);
pstrcpy(sam_subst, pdb_get_logon_script(user));
standard_sub_advanced(-1, sam_user, "", gid, sam_user, sam_subst);
pdb_set_logon_script(user, sam_subst, True);
if (!pdb_set_logon_script(user, sam_subst, True)) return False;
pstrcpy(sam_subst, pdb_get_profile_path(user));
standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
pdb_set_profile_path(user, sam_subst, True);
if (!pdb_set_profile_path(user, sam_subst, True)) return False;
pstrcpy(sam_subst, pdb_get_homedir(user));
standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
pdb_set_homedir(user, sam_subst, True);
if (!pdb_set_homedir(user, sam_subst, True)) return False;
/* increment to next in line */
global_tdb_ent.key = tdb_nextkey(global_tdb_ent.passwd_tdb, global_tdb_ent.key);
@ -578,13 +578,13 @@ BOOL pdb_getsampwnam (SAM_ACCOUNT *user, const char *sname)
sam_user = pdb_get_username(user);
pstrcpy(sam_subst, pdb_get_logon_script(user));
standard_sub_advanced(-1, sam_user, "", gid, sam_user, sam_subst);
pdb_set_logon_script(user, sam_subst, True);
if (!pdb_set_logon_script(user, sam_subst, True)) return False;
pstrcpy(sam_subst, pdb_get_profile_path(user));
standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
pdb_set_profile_path(user, sam_subst, True);
if (!pdb_set_profile_path(user, sam_subst, True)) return False;
pstrcpy(sam_subst, pdb_get_homedir(user));
standard_sub_advanced(-1, pdb_get_username(user), "", gid, pdb_get_username(user), sam_subst);
pdb_set_homedir(user, sam_subst, True);
if (!pdb_set_homedir(user, sam_subst, True)) return False;
}
else {
DEBUG(0,("pdb_getsampwent: getpwnam(%s) return NULL. User does not exist!\n",

View File

@ -1183,11 +1183,15 @@ static NTSTATUS cmd_spoolss_getprintprocdir(struct cli_state *cli,
return NT_STATUS_OK;
}
asprintf(&servername, "\\\\%s", cli->desthost);
if (asprintf(&servername, "\\\\%s", cli->desthost) < 0)
return NT_STATUS_NO_MEMORY;
strupper(servername);
asprintf(&environment, "%s", (argc == 3) ? argv[2] :
PRINTER_DRIVER_ARCHITECTURE);
if (asprintf(&environment, "%s", (argc == 3) ? argv[2] :
PRINTER_DRIVER_ARCHITECTURE) < 0) {
SAFE_FREE(servername);
return NT_STATUS_NO_MEMORY;
}
result = cli_spoolss_getprintprocessordirectory(
cli, mem_ctx, servername, environment, procdir);