From: Wayne Davison <wayned@users.sourceforge.net>
To: Peter Stephenson <pws@csr.com>
Cc: zsh-workers@sunsite.dk
Subject: Re: difflog.pl and "security"
Date: Mon, 3 Dec 2007 13:36:04 -0800 [thread overview]
Message-ID: <20071203213604.GA6645@blorf.net> (raw)
In-Reply-To: <20071203104256.09dc9684@news01>
[-- Attachment #1: Type: text/plain, Size: 535 bytes --]
On Mon, Dec 03, 2007 at 10:42:56AM +0000, Peter Stephenson wrote:
> Maybe we should simply leave it out of the distribution (but leave it in
> the archive), since it's essentially no use unless you have a CVS tree.
Seems quite reasonable to me. I also coded up an improved version that
uses File::Temp. I also changed the opening of the DIFF pipe to use a
newer, safer exec syntax (since we don't need this to be very portable,
I figure the perl version should be recent enough for anyone who might
be using the script).
..wayne..
[-- Attachment #2: difflog.patch --]
[-- Type: text/x-diff, Size: 1399 bytes --]
--- difflog.pl 18 Apr 2002 14:35:17 -0000 1.3
+++ difflog.pl 3 Dec 2007 21:32:03 -0000
@@ -2,10 +2,9 @@
use strict;
use IO::File;
+use File::Temp qw(tempfile);
my @differ = qw(diff -bw);
-my $oldtmp = "/tmp/difflog$$.old";
-my $newtmp = "/tmp/difflog$$.new";
my $newfn = pop(@ARGV);
my $oldfn = pop(@ARGV);
@@ -36,16 +35,17 @@ while ($old < @oldentries && $new < @new
else
{
if ($oldhash{$oldentries[$old]} ne $newhash{$newentries[$new]}) {
- my $oldfh = new IO::File("/tmp/difflog$$.old", 'w');
- $oldfh->print($oldhash{$oldentries[$old]});
- $oldfh->close();
- my $newfh = new IO::File("/tmp/difflog$$.new", 'w');
- $newfh->print($newhash{$newentries[$new]});
- $newfh->close();
- open(DIFF, join(' ', @differ, @ARGV, $oldtmp, $newtmp, '|'));
+ my($oldfh, $oldtmp) = tempfile('difflog-XXXXXXXX', SUFFIX => '.old', DIR => '/tmp');
+ print $oldfh $oldhash{$oldentries[$old]};
+ close $oldfh;
+ my($newfh, $newtmp) = tempfile('difflog-XXXXXXXX', SUFFIX => '.new', DIR => '/tmp');
+ print $newfh $newhash{$newentries[$new]};
+ close $newfh;
+ open(DIFF, '-|', @differ, @ARGV, $oldtmp, $newtmp) or die $!;
my @lines = <DIFF>;
close(DIFF);
- unlink </tmp/difflog$$.*>;
+ unlink($oldtmp);
+ unlink($newtmp);
if (@lines)
{
print "diff for ", $oldentries[$old], ":\n";
prev parent reply other threads:[~2007-12-03 21:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-02 21:40 Clint Adams
2007-12-03 1:45 ` Bart Schaefer
2007-12-03 10:42 ` Peter Stephenson
2007-12-03 16:33 ` Bart Schaefer
2007-12-03 17:36 ` Peter Stephenson
2007-12-03 18:37 ` Bart Schaefer
2007-12-03 21:36 ` Wayne Davison [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071203213604.GA6645@blorf.net \
--to=wayned@users.sourceforge.net \
--cc=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).