summaryrefslogtreecommitdiff
path: root/source3/lib/fault.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-15 14:19:52 -0800
committerJeremy Allison <jra@samba.org>2007-11-15 14:19:52 -0800
commit68be9a820059ee96dd26c527efd7c14e679d3f2c (patch)
treec3c853a01013fc7977ab02a31e673fe17b4135e6 /source3/lib/fault.c
parent8e1b0f81c27dc332560f19de27fb86ac96c59775 (diff)
downloadsamba-68be9a820059ee96dd26c527efd7c14e679d3f2c.tar.gz
samba-68be9a820059ee96dd26c527efd7c14e679d3f2c.tar.bz2
samba-68be9a820059ee96dd26c527efd7c14e679d3f2c.zip
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)
Diffstat (limited to 'source3/lib/fault.c')
-rw-r--r--source3/lib/fault.c29
1 files changed, 21 insertions, 8 deletions
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
{