Package: libproc-pid-file-perl
Version: 1.27-3
Severity: important
Tags: upstream patch jessie stretch
Severity justification: cron spam from every script using Proc::PID::File to
avoid overlapping runs.
$ perl -MProc::PID::File -wE'die if Proc::PID::File->running({dir => "."})'
Use of uninitialized value $fh in pattern match (m//) at
/usr/share/perl5/Proc/PID/File.pm line 288.
281 sub read {
282 my ($self, $fh) = @_;
283
284 sysopen $fh, $self->{path}, O_RDWR|O_CREAT
285 || die qq/Cannot open pid file "$self->{path}": $!\n/;
286 flock($fh, LOCK_EX | LOCK_NB)
287 || die qq/pid "$self->{path}" already locked: $!\n/;
288 my ($pid) = <$fh> =~ /^(\d+)/;
289 close $fh if @_ == 1;
290
291 $self->debug("read(\"$self->{path}\") = " . ($pid || ""));
292 return $pid;
293 }
The reason for the warning is that <$fh> is undefined, since the PID file is
just created and empty.
The attached patch avoids the warning by applying the match only when <$fh>
returns a value.
I am willing to help get this fixed (in stable too) in whatever way is
preferred - patch (provided), NMU or takeover under the pkg-perl umbrella.
Cheers,
dam
-- System Information:
Debian Release: stretch/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'oldstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.2.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=bg_BG.UTF-8, LC_CTYPE=bg_BG.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages libproc-pid-file-perl depends on:
ii perl 5.20.2-6
Versions of packages libproc-pid-file-perl recommends:
ii procps 2:3.3.10-4
libproc-pid-file-perl suggests no packages.
-- no debconf information
Description: fix usage of undefined value in pattern match
$perl -MProc::PID::File -wE'die if Proc::PID::File->running({dir => "."})'
Use of uninitialized value $fh in pattern match (m//) at·
/usr/share/perl5/Proc/PID/File.pm line 288.
This happens when the program runs for the first time and there is no PID
file.
Author: Damyan Ivanov <[email protected]>
--- a/File.pm
+++ b/File.pm
@@ -285,7 +285,8 @@ sub read {
|| die qq/Cannot open pid file "$self->{path}": $!\n/;
flock($fh, LOCK_EX | LOCK_NB)
|| die qq/pid "$self->{path}" already locked: $!\n/;
- my ($pid) = <$fh> =~ /^(\d+)/;
+ my $pid = <$fh>;
+ $pid =~ /^(\d+)/ if defined($pid);
close $fh if @_ == 1;
$self->debug("read(\"$self->{path}\") = " . ($pid || ""));