pcp
[Top] [All Lists]

Re: [pcp] pcp updates - porting to NetBSD

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] pcp updates - porting to NetBSD
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Fri, 22 Feb 2013 20:53:17 +1100
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <103619508.7665555.1361525596066.JavaMail.root@xxxxxxxxxx>
References: <103619508.7665555.1361525596066.JavaMail.root@xxxxxxxxxx>
Reply-to: kenj@xxxxxxxxxxxxxxxx
On Fri, 2013-02-22 at 04:33 -0500, Nathan Scott wrote:
> 
> ----- Original Message -----
> > [...]  We probably need a hard-coded fail-safe like this
> > for such a pathological case...
> > 
> > diff --git a/src/libpcp/src/util.c b/src/libpcp/src/util.c
> > index a92f98c..6f07b13 100644
> > --- a/src/libpcp/src/util.c
> > +++ b/src/libpcp/src/util.c
> > @@ -1091,9 +1091,10 @@ vpmprintf(const char *msg, va_list arg)
> >         int     fd = -1;
> >  
> >  #if HAVE_MKSTEMP
> > +       char *tmpdir = pmGetConfig("PCP_TMP_DIR");
> >         fname = (char *)malloc(MAXPATHLEN+1);
> >         if (fname == NULL) goto fail;
> > -       snprintf(fname, MAXPATHLEN, "%s/pcp-XXXXXX",
> > pmGetConfig("PCP_TMP_DIR"))
> > +       snprintf(fname, MAXPATHLEN, "%s/pcp-XXXXXX", tmpdir ? tmpdir
> > : "/tmp"));
> 
> The theory was good, but the patch didn't count on pmGetConfig always
> returning a value (empty string if not found, not NULL).
> 
> I've fixed it up & verified the test now passes - will commit shortly.
> 

OK we're doubling up here ... I'll compare your patch with my fix ...
I've also changed to pmGetConfig man page so it no longer lies!

<Prev in Thread] Current Thread [Next in Thread>