On Wed, May 28, 2003 at 12:49:26AM +0800, Autrijus Tang wrote:
> On Tue, May 27, 2003 at 09:23:53AM -0700, Jonathan Leffler wrote:
> > I just ran into problems installing PAR 0.68 on Solaris 7 with Perl
> > 5.8.0 (-V output below signature).
> 
> Hmm, so line 47 in myldr/mktmpdir.c:
> 
>         if ( (envtmp = getenv(tmpdir)) )
> 
> is failing on Solaris and Linux, whilst Darwin, FreeBSD and Win32
> works fine.  As I do not have access to the two platforms at question,
> and my C-fu is quite lacking, can you (or Markus, or others on the list)
> help sanity-checking this line?

It seemed to SEGV for me on a PPC linux box but not an x86 box, but this
could be down to environment, or to different strlen implementations.

The SEGV was due to getenv() calling strlen() on its argument, and strlen
SEGV-ing because the argument (tmpdir) was NULL. I *think* that the logic
of mktmpdir.c is buggy. (See the patch context)
As is the condition of the for loop is that tmpdir is NULL, and tmpdir is
never assigned to, hence inside the for loop tmpdir will always be NULL.
Yet you are calling getenv with tmpdir. I think that you meant to use
tmpval, but someone familiar with the intent of the code should check this.

Nicholas Clark

--- myldr/mktmpdir.c.orig       2003-05-25 19:07:50.000000000 +0100
+++ myldr/mktmpdir.c    2003-05-27 20:37:11.000000000 +0100
@@ -44,7 +44,7 @@
 
     for ( i = 0 ; tmpdir == NULL && strlen(tmpval = tmpenv[i]) > 0 ; i++ ) {
         /* fprintf(stderr, "%s: testing env var %s.\n", argv[0], tmpval); */
-        if ( (envtmp = getenv(tmpdir)) )
+        if ( (envtmp = getenv(tmpval)) )
         {
             if ( PAR_lstat(envtmp, &statbuf) == 0 &&
                  ( S_ISDIR(statbuf.st_mode) ||

Reply via email to