pcp
[Top] [All Lists]

Re: [pcp] pcp updates - porting to NetBSD

To: kenj@xxxxxxxxxxxxxxxx
Subject: Re: [pcp] pcp updates - porting to NetBSD
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Fri, 22 Feb 2013 04:33:16 -0500 (EST)
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <1902857525.7634884.1361521685182.JavaMail.root@xxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>

----- 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.

cheers.

--
Nathan

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