Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make it less likely to stumble upon file name replacement
Of course that's not the right way to fix it, but it is good enough for now.
Ideally EvalbotExecuter should return the filename that was used, but current
fix is probably good enough (even though it feels weird).
  • Loading branch information
AlexDaniel committed Jun 10, 2016
1 parent 282650f commit fa2e44f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion evalbot.pl
Expand Up @@ -298,7 +298,7 @@ package Evalbot;
my $null = "\N{SYMBOL FOR NULL}";
$response =~ s/\n/$newline/g;
$response =~ s/\x00/$null/g;
$response =~ s|/tmp/\w{10}|/tmp/tmpfile|g;
$response =~ s|/tmp/evalbot-file-\w{10}|/tmp/tmpfile|g;
$response = IRC::FromANSI::Tiny::convert($response);

my $format_len = length(encode_utf8(sprintf $format_res, $prefix, ''));
Expand Down
4 changes: 2 additions & 2 deletions lib/EvalbotExecuter.pm
Expand Up @@ -119,7 +119,7 @@ sub _fork_and_eval {
my ($program, $executer, $ename) = @_;

# the forked process should write its output to this tempfile:
my ($fh, $filename) = tempfile();
my ($fh, $filename) = tempfile('evalbot-file-XXXXXXXXXX', TMPDIR => 1);
chmod 0644, $filename;

my $fork_val = fork;
Expand Down Expand Up @@ -195,7 +195,7 @@ sub _auto_execute {
$program = $executer->{program_munger}->($program);
}
my $cmd = $executer->{cmd_line} or confess "No command line given\n";
my ($prog_fh, $program_file_name) = tempfile();
my ($prog_fh, $program_file_name) = tempfile('evalbot-file-XXXXXXXXXX', TMPDIR => 1);
binmode $prog_fh, ':encoding(UTF-8)';
print $prog_fh $program;
close $prog_fh;
Expand Down

0 comments on commit fa2e44f

Please sign in to comment.