summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/debug.c10
-rw-r--r--source3/lib/substitute.c24
-rw-r--r--source3/lib/time.c4
-rw-r--r--source3/libsmb/trusts_util.c2
-rw-r--r--source3/rpcclient/cmd_spoolss.c12
-rw-r--r--source3/smbd/change_trust_pw.c2
-rw-r--r--source3/web/swat.c6
7 files changed, 38 insertions, 22 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index c4a0d1b47b..a76a8dbf53 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -1029,12 +1029,14 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
/* Print it all out at once to prevent split syslog output. */
if( lp_debug_prefix_timestamp() ) {
(void)Debug1( "[%s, %2d%s] ",
- current_timestring(lp_debug_hires_timestamp()), level,
- header_str);
+ current_timestring(debug_ctx(),
+ lp_debug_hires_timestamp()),
+ level, header_str);
} else {
(void)Debug1( "[%s, %2d%s] %s:%s(%d)\n",
- current_timestring(lp_debug_hires_timestamp()), level,
- header_str, file, func, line );
+ current_timestring(debug_ctx(),
+ lp_debug_hires_timestamp()),
+ level, header_str, file, func, line );
}
}
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 6ecc3fc635..62dfdb56b5 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -548,6 +548,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
fstring pidstr, vnnstr;
char addr[INET6_ADDRSTRLEN];
const char *local_machine_name = get_local_machine_name();
+ TALLOC_CTX *tmp_ctx = NULL;
/* workaround to prevent a crash while looking at bug #687 */
@@ -561,12 +562,14 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
DEBUG(0, ("alloc_sub_basic: Out of memory!\n"));
return NULL;
}
-
+
+ tmp_ctx = talloc_stackframe();
+
for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
r = NULL;
b = a_string;
-
+
switch (*(p+1)) {
case 'U' :
r = strdup_lower(smb_name);
@@ -581,7 +584,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
if (r == NULL) {
goto error;
}
- pass = Get_Pwnam_alloc(talloc_tos(), r);
+ pass = Get_Pwnam_alloc(tmp_ctx, r);
if (pass != NULL) {
a_string = realloc_string_sub(
a_string, "%G",
@@ -631,7 +634,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
a_string = realloc_string_sub(a_string, "%R", remote_proto);
break;
case 'T' :
- a_string = realloc_string_sub(a_string, "%T", current_timestring(False));
+ a_string = realloc_string_sub(a_string, "%T", current_timestring(tmp_ctx, False));
break;
case 'a' :
a_string = realloc_string_sub(a_string, "%a",
@@ -669,17 +672,20 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
p++;
SAFE_FREE(r);
-
- if ( !a_string ) {
- return NULL;
+
+ if (a_string == NULL) {
+ goto done;
}
}
- return a_string;
+ goto done;
error:
SAFE_FREE(a_string);
- return NULL;
+
+done:
+ TALLOC_FREE(tmp_ctx);
+ return a_string;
}
/****************************************************************************
diff --git a/source3/lib/time.c b/source3/lib/time.c
index f98e03197f..e5fd929d0f 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -687,7 +687,7 @@ int set_server_zone_offset(time_t t)
Return the date and time as a string
****************************************************************************/
-char *current_timestring(bool hires)
+char *current_timestring(TALLOC_CTX *ctx, bool hires)
{
fstring TimeBuf;
struct timeval tp;
@@ -739,7 +739,7 @@ char *current_timestring(bool hires)
}
#endif
}
- return talloc_strdup(talloc_tos(), TimeBuf);
+ return talloc_strdup(ctx, TimeBuf);
}
diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c
index c079fb149a..8c2f69cee3 100644
--- a/source3/libsmb/trusts_util.c
+++ b/source3/libsmb/trusts_util.c
@@ -123,7 +123,7 @@ NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *m
if (NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("%s : trust_pw_change_and_store_it: Changed password.\n",
- current_timestring(False)));
+ current_timestring(debug_ctx(), False)));
/*
* Return the result of trying to write the new password
* back into the trust account file.
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 5e0f694cf9..7530ab1911 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -1966,13 +1966,15 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
PRINTER_INFO_CTR ctr;
PRINTER_INFO_0 info;
REGISTRY_VALUE value;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
/* parse the command arguements */
if (argc < 5) {
printf ("Usage: %s <printer> <string|binary|dword|multistring>"
" <value> <data>\n",
argv[0]);
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto done;
}
slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
@@ -2000,7 +2002,8 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (value.type == REG_NONE) {
printf("Unknown data type: %s\n", argv[2]);
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto done;
}
/* get a printer handle */
@@ -2019,7 +2022,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", current_timestring(True));
+ printf("%s\n", current_timestring(tmp_ctx, True));
printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id);
/* Set the printer data */
@@ -2105,11 +2108,12 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", current_timestring(True));
+ printf("%s\n", current_timestring(tmp_ctx, True));
printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id);
done:
/* cleanup */
+ TALLOC_FREE(tmp_ctx);
if (opened_hnd)
rpccli_spoolss_close_printer(cli, mem_ctx, &pol);
diff --git a/source3/smbd/change_trust_pw.c b/source3/smbd/change_trust_pw.c
index fc58e97ea7..4773eeff86 100644
--- a/source3/smbd/change_trust_pw.c
+++ b/source3/smbd/change_trust_pw.c
@@ -90,7 +90,7 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
failed:
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("%s : change_trust_account_password: Failed to change password for domain %s.\n",
- current_timestring(False), domain));
+ current_timestring(debug_ctx(), False), domain));
}
else
DEBUG(5,("change_trust_account_password: sucess!\n"));
diff --git a/source3/web/swat.c b/source3/web/swat.c
index bb418db04b..6d8f4cae06 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -438,11 +438,15 @@ static bool load_config(bool save_def)
****************************************************************************/
static void write_config(FILE *f, bool show_defaults)
{
+ TALLOC_CTX *ctx = talloc_stackframe();
+
fprintf(f, "# Samba config file created using SWAT\n");
fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr());
- fprintf(f, "# Date: %s\n\n", current_timestring(False));
+ fprintf(f, "# Date: %s\n\n", current_timestring(ctx, False));
lp_dump(f, show_defaults, iNumNonAutoPrintServices);
+
+ TALLOC_FREE(ctx);
}
/****************************************************************************