W3C home > Mailing lists > Public > html-tidy@w3.org > April to June 2001

Problem w/ ExpandTilde [patch]

From: Adrian Mugnolo <adrianm@yahoo-inc.com>
Date: Wed, 11 Apr 2001 10:36:24 -0300 (ART)
Message-Id: <200104111336.KAA14917@jazz.ar.yahoo.com>
To: html-tidy@w3.org

[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);

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:38:49 UTC