Problem w/ ExpandTilde [patch]

Hi,

[I sent a similar message to Dave Raggett but then I thought someone
else in the list might be encountering the same problem.]

A couple of weeks ago I came across this problem when I was trying to
use Tidy as a formatting "output pipe" for a CGI program written in
Perl.  I first suspected of the binary I was using (the one distributed
thru FreeBSD's port collection) but then I tracked down the problem to
the ExpandTilde function.

This is a Perl CGI script that shows the problem:

        print 'Content-type: text/html', "\n\n";
        open STDOUT, '|tidy 2>/dev/null';
        print '<h1>Hello</h1>';
        close STDOUT;

The short program was dumping core because unpriviledged user nobody
doesn't have a HOME environment variable set (not at least on FreeBSD),
thus causing an error when trying to call strlen with home_dir as
argument (line 399 after patch).

Patch follows:

*** config.c    Fri Aug  4 13:21:05 2000
--- config1.c   Mon Apr  9 14:18:05 2001
***************
*** 364,369 ****
--- 364,373 ----
      if (filename[1] == '/')
      {
          home_dir = getenv("HOME");
+ 
+         if (!home_dir)
+             return(filename);
+ 
          filename++;
      }
      else

HTH

Received on Wednesday, 11 April 2001 09:36:36 UTC