httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn <gs-apache-...@gluelogic.com>
Subject Re: r->filename.
Date Sat, 25 Oct 2003 18:54:06 GMT
On Sat, Oct 25, 2003 at 11:33:35AM -0700, Stas Bekman wrote:
> Ted Rolle wrote:
> [...]
> >The calling module has the responsibility of providing a good r->filename,
> >even when it's not used.
> 
> what's a good r->filename? /dev/null sounds good to me.

How about "" as in the empty string containing only the '\0' character?
This way, filters after the trans_hook could be sure that r->filename
is never NULL and at the same time, any stat calls on "" will fail.
Smarter modules would be able to check
  if (*r->filename != '\0') {
      ....
  }
and modules that require a mapping to the filesystem could quickly do
  if (*r->filename == '\0') {
      return DECLINED;
  }
to simply decline when they detect that there is no filesystem mapping.

Cheers,
Glenn

> I believe if you want to make fix-it-behind-the-scenes for all, httpd needs 
> to check whether r->filename is set after trans_hook is done, and if it's 
> NULL, set it to that good filename. Hopefully none of the following hooks 
> will try to use that good filename for anything. The fact that we get the 
> segfault is that it *is* being used when it shouldn't (since there is no 
> corresponding filename for the virtual resource), so it's the right thing 
> to check for r->filename not being NULL before trying to use it.

Mime
View raw message