Package: libdpkg-perl
Version: 1.17.24
Severity: minor
Tags: patch

To reproduce:

$ perl -MDpkg::Control::Info -E 'my $info =
Dpkg::Control::Info->new("debian/control"); say $info;'
Can't use an undefined value as a symbol reference at
/usr/share/perl5/Dpkg/Control/Info.pm line 185.

(I stumbled over this while running a script of mine under a GUI Perl debugger
- it crashed
when I tried to mouse over a variable holding a Dpkg::Control::Info object,
same happens
when you try to "p $info" in the command line debugger.)

Problem is that _stringify() (overloading the "" operator) is implemented using
output()
with no argument. Since output() may also take a filehandle as argument, this
means
the value of the filehandle argument is undef in this call. But
Dpkg::Control::Info's
implementation of output() uses the filehandle without checking.

Patch attached.



-- System Information:
Debian Release: 8.0
  APT prefers vivid
  APT policy: (500, 'vivid'), (500, 'buildd-unstable'), (500, 'unstable'), (1, 
'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.19.3 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libdpkg-perl depends on:
ii  dpkg              1.17.24
ii  libtimedate-perl  2.3000-2
ii  perl              5.20.2-3

Versions of packages libdpkg-perl recommends:
ii  bzip2                   1.0.6-7+b3
ii  libfile-fcntllock-perl  0.22-1+b1
ii  xz-utils                5.1.1alpha+20120614-2+b3

Versions of packages libdpkg-perl suggests:
ii  bcc [c-compiler]        0.16.17-3.1
ii  binutils                2.25-6
ii  clang-3.5 [c-compiler]  1:3.5.1-1~exp1
ii  clang-3.6 [c-compiler]  1:3.6-2
ii  debian-keyring          2015.03.30
ii  gcc [c-compiler]        4:5-3
ii  gcc-4.9 [c-compiler]    4.9.2-10
ii  gcc-5 [c-compiler]      5-20150329-1
ii  gnupg                   1.4.19-1
ii  gnupg2                  2.1.2-2
ii  gpgv                    1.4.19-1
ii  gpgv2                   2.1.2-2
ii  patch                   2.7.5-1

-- no debconf information
--- dpkg-1.17.24-ORIG/scripts/Dpkg/Control/Info.pm	2015-04-04 13:06:55.756943138 +0200
+++ dpkg-1.17.24/scripts/Dpkg/Control/Info.pm	2015-04-04 13:07:09.805117596 +0200
@@ -182,7 +182,7 @@
     my $str;
     $str .= $self->{source}->output($fh);
     foreach my $pkg (@{$self->{packages}}) {
-	print { $fh } "\n";
+	print { $fh } "\n" if defined $fh;
 	$str .= "\n" . $pkg->output($fh);
     }
     return $str;

Reply via email to