From 6f46f75dfc2c80b99a6a5fb277bab456a5fd247b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 3 Dec 2007 17:17:05 -0800 Subject: Make strhex_to_str clear on string limits. Remove pstring from web/*.c Jeremy. (This used to be commit f9c8d62389f8cb47837e5360209936176537df13) --- source3/web/statuspage.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'source3/web/statuspage.c') diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index b59c5cdf43..647e4fcb5b 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -20,7 +20,7 @@ #include "includes.h" #include "web/swat_proto.h" -#define _(x) lang_msg_rotate(x) +#define _(x) lang_msg_rotate(talloc_tos(),x) #define PIDMAP struct PidMap @@ -99,11 +99,20 @@ static char *mapPid2Machine (struct server_id pid) return pidbuf; } -static char *tstring(time_t t) +static const char *tstring(TALLOC_CTX *ctx, time_t t) { - static pstring buf; - pstrcpy(buf, time_to_asc(t)); - all_string_sub(buf," "," ",sizeof(buf)); + char *buf; + buf = talloc_strdup(ctx, time_to_asc(t)); + if (!buf) { + return ""; + } + buf = talloc_all_string_sub(ctx, + buf, + " ", + " "); + if (!buf) { + return ""; + } return buf; } @@ -162,7 +171,7 @@ static void print_share_mode(const struct share_mode_entry *e, push_utf8_allocate(&utf8_fname, fname); printf("%s%s\n", - utf8_fname,tstring(e->time.tv_sec)); + utf8_fname,tstring(talloc_tos(),e->time.tv_sec)); SAFE_FREE(utf8_fname); } @@ -199,7 +208,7 @@ static int traverse_fn2(struct db_record *rec, printf("%s%s%s%s\n", procid_str_static(&crec->pid), crec->machine, crec->addr, - tstring(crec->start)); + tstring(talloc_tos(),crec->start)); if (geteuid() == 0) { printf("\n", procid_str_static(&crec->pid)); @@ -222,7 +231,7 @@ static int traverse_fn3(struct db_record *rec, crec->servicename, uidtoname(crec->uid), gidtoname(crec->gid),procid_str_static(&crec->pid), crec->machine, - tstring(crec->start)); + tstring(talloc_tos(),crec->start)); return 0; } @@ -235,6 +244,7 @@ void status_page(void) int refresh_interval=30; int nr_running=0; bool waitup = False; + TALLOC_CTX *ctx = talloc_stackframe(); smbd_pid = pid_to_procid(pidfile_pid("smbd")); @@ -311,7 +321,7 @@ void status_page(void) } connections_forall(traverse_fn1, NULL); - + initPid2Machine (); printf("

%s

\n", _("Server Status")); @@ -438,4 +448,5 @@ void status_page(void) refresh_interval*1000); printf("//-->\n\n"); } + TALLOC_FREE(ctx); } -- cgit