From 68be9a820059ee96dd26c527efd7c14e679d3f2c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Nov 2007 14:19:52 -0800 Subject: More pstring removal. This one was tricky. I had to add one horror (pstring_clean_name()) which will have to remain until I've removed all pstrings from the client code. Jeremy. (This used to be commit 1ea3ac80146b83c2522b69e7747c823366a2b47d) --- source3/lib/fault.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'source3/lib/fault.c') diff --git a/source3/lib/fault.c b/source3/lib/fault.c index 6ab1a07900..52c4ae63e5 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -24,7 +24,7 @@ #endif static void (*cont_fn)(void *); -static pstring corepath; +static char *corepath; /******************************************************************* report a fault @@ -93,11 +93,13 @@ make all the preparations to safely dump a core file void dump_core_setup(const char *progname) { - pstring logbase; - char * end; + char *logbase = NULL; + char *end = NULL; if (lp_logfile() && *lp_logfile()) { - snprintf(logbase, sizeof(logbase), "%s", lp_logfile()); + if (asprintf(&logbase, "%s", lp_logfile()) < 0) { + return; + } if ((end = strrchr_m(logbase, '/'))) { *end = '\0'; } @@ -106,21 +108,32 @@ void dump_core_setup(const char *progname) * line by the -l option but the "log file" option is not set * in smb.conf. */ - snprintf(logbase, sizeof(logbase), "%s", dyn_LOGFILEBASE); + if (asprintf(&logbase, "%s", dyn_LOGFILEBASE) < 0) { + return; + } } SMB_ASSERT(progname != NULL); - snprintf(corepath, sizeof(corepath), "%s/cores", logbase); + if (asprintf(&corepath, "%s/cores", logbase) < 0) { + SAFE_FREE(logbase); + return; + } mkdir(corepath,0700); - snprintf(corepath, sizeof(corepath), "%s/cores/%s", - logbase, progname); + SAFE_FREE(corepath); + if (asprintf(&corepath, "%s/cores/%s", + logbase, progname) < 0) { + SAFE_FREE(logbase); + return; + } mkdir(corepath,0700); sys_chown(corepath,getuid(),getgid()); chmod(corepath,0700); + SAFE_FREE(corepath); + #ifdef HAVE_GETRLIMIT #ifdef RLIMIT_CORE { -- cgit