Package: dpkg-dev
Version: 1.16.0.3
Followup-For: Bug #633539

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi

I noticed dpkg-gencontrol and dpkg-shlibdeps has a similar issue, so
here is a (separate) patch for them.  Feel free to --squash them (or
ask me to submit a merged patch).

~Niels

- -- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.39-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dpkg-dev depends on:
ii  base-files            6.3                Debian base system miscellaneous f
ii  binutils              2.21.52.20110606-2 The GNU assembler, linker and bina
ii  bzip2                 1.0.5-6            high-quality block-sorting file co
ii  libdpkg-perl          1.16.0.3           Dpkg perl modules
ii  make                  3.81-8.1           An utility for Directing compilati
ii  patch                 2.6.1-2            Apply a diff file to an original
ii  xz-utils              5.0.0-2            XZ-format compression utilities

Versions of packages dpkg-dev recommends:
ii  build-essential               11.5       Informational list of build-essent
ii  fakeroot                      1.16-1     tool for simulating superuser priv
ii  gcc [c-compiler]              4:4.6.0-6  GNU C compiler
ii  gcc-4.5 [c-compiler]          4.5.3-3    The GNU C compiler
ii  gcc-4.6 [c-compiler]          4.6.1-1    GNU C compiler
ii  gnupg                         1.4.11-3   GNU privacy guard - a free PGP rep
ii  gpgv                          1.4.11-3   GNU privacy guard - signature veri
pn  libalgorithm-merge-perl       <none>     (no description available)

Versions of packages dpkg-dev suggests:
ii  debian-keyring                2011.03.03 GnuPG keys of Debian Developers

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJOGuZcAAoJEAVLu599gGRCUagQALD4OnM3tkvt38j9kooC5ks9
xyDXHhGCVWidOPFGearN+DCCj2nIQhYvAZCOQysi4139o50PFQE7bo0CtDB5Mrmx
G+0Ve/FanFx/c3UUtcTTMAoOZ8A8q6PNbm5IHFsaC0Dhk4op0jq8lR1kRO6ZUXXA
o5vzrcPxL+X8lCiWQR5adJRCOJfK/cqxUtxedAdPEFktGby/T5pjAYnO5ZXWy9BY
6XztH9CnX/ZcVsGSdJPr9YpqpfLkGFLbKvrSPgbMbUgT/ylOYbQAl7CI278CzOpF
dlq+88KDsttLf4h9nqE1edwZIK4xTBALIeXBja/trskU5KgD5ScOjA8d8eZ1Zmi3
GPg0VC7nwuCjmUTSaJzK18NXUwnLFhY562Mb2PD5FZatr7pC+TUgELUyKOzsoNoo
uDb/68IWmKQoKz5mWTrFM8oToF0DXLsZ9X1JtyTeZW7tFGr8WaywgBxzGfyw7QST
qMhDds9lt/5qF2Xy+ObdpsE6oRuLwjEg+GzEYQD6z2AFf+OcZ7vadTKzwZ3Hh6do
hLMVJV3ruE1wA34aRzTQI+hYyg3K6LC98xf3DpgtFkN+zoEfwiV/FzK4xzTGeKps
WWCFUk1UCZUhNnj00Q8jDnEmvUsKgxvXJR2qn/vnZJtefxnuqIzu5/Xxy6IEAjGE
BrRF6jBnX5+LpZIVZVYw
=sphh
-----END PGP SIGNATURE-----
>From b33b3e4ac9c5342a31d3eb4a2253a07737d8b6fb Mon Sep 17 00:00:00 2001
From: Niels Thykier <ni...@thykier.net>
Date: Mon, 11 Jul 2011 13:59:10 +0200
Subject: [PATCH] dpkg-dev: Fail on if closing an output handle fails

This patch makes dpkg-gencontrol and dpkg-shlibdeps fail if their
call to close (on output handles) suggests an issue.  This prevents
them from silently producing incomplete files and may provide a
better error than the following rename failing.
---
 scripts/dpkg-gencontrol.pl |    3 ++-
 scripts/dpkg-shlibdeps.pl  |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl
index f0e6964..d23bc2f 100755
--- a/scripts/dpkg-gencontrol.pl
+++ b/scripts/dpkg-gencontrol.pl
@@ -375,7 +375,8 @@ $fields->apply_substvars($substvars);
 $fields->output($fh_output);
 
 if (!$stdout) {
-    close($fh_output);
+    close($fh_output) ||
+        syserr(_g("cannot close new output control file \`%s'"), "$cf.new");
     rename("$cf.new", "$cf") ||
         syserr(_g("cannot install output control file \`%s'"), $cf);
 }
diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl
index 790ba39..0856100 100755
--- a/scripts/dpkg-shlibdeps.pl
+++ b/scripts/dpkg-shlibdeps.pl
@@ -520,7 +520,8 @@ foreach my $field (reverse @depfields) {
 
 # Replace old file by new one
 if (!$stdout) {
-    close($fh);
+    close($fh) ||
+       syserr(_g("close new substvars file \`%s'"), "$varlistfile.new");
     rename("$varlistfile.new",$varlistfile) ||
        syserr(_g("install new varlist file \`%s'"), $varlistfile);
 }
-- 
1.7.5.4

Reply via email to