#!/usr/local/bin/perl -T # $Id: getmsg.cgi,v 1.1 1998-02-26 23:49:52 jfieber Exp $ require "./cgi-lib.pl"; require "./cgi-style.pl"; my $messageroot = "/usr/local/www/db/text/"; &ReadParse(*formdata); &Fetch($formdata{'fetch'}); exit 0; sub Fetch { local ($docid) = @_; local ($start, $end, $file) = split(/ /, $docid); print &short_html_header("FreeBSD Mail Archives"); # # Check to ensure that (a) the specified file starts # with an approved pathname and (b) that it contains no # relative components (eg ..). This is so that arbitrary # files cannot be accessed. # $file =~ s/\.\.//g; $file =~ s|/+|/|; if ($file =~ /^$messageroot/ && open(DATA, $file)) { seek DATA, $start, 0; read DATA, $message, $end - $start; close(DATA); print &MessageToHTML($message); } else { print "
The specified message cannot be accessed.
\n"; } print &html_footer; print "