Kaynağa Gözat

dpkg-divert: Do not allow diverting a file to itself

This was causing the file to get removed.

Closes: #312206
Guillem Jover 16 yıl önce
ebeveyn
işleme
39c49a58f2
2 değiştirilmiş dosya ile 3 ekleme ve 0 silme
  1. 2 0
      debian/changelog
  2. 1 0
      scripts/dpkg-divert.pl

+ 2 - 0
debian/changelog

@@ -27,6 +27,8 @@ dpkg (1.15.6) UNRELEASED; urgency=low
     applies the overrides, so better to signal this earlier.
   * Add sparc64 to cputable. Thanks to Aurelien Jarno <aurel32@debian.org>.
     Closes: #523456
+  * Do not allow diverting a file to itself, which makes the file to get
+    removed. Closes: #312206
 
   [ Updated man page translations ]
   * French (Christian Perrier): correcting inconsistencies for the translation

+ 1 - 0
scripts/dpkg-divert.pl

@@ -164,6 +164,7 @@ if ($mode eq 'add') {
     -d $file && badusage(_g("Cannot divert directories"));
     $divertto= "$file.distrib" unless defined($divertto);
     $divertto =~ m#^/# || badusage(sprintf(_g("filename \"%s\" is not absolute"), $divertto));
+    $file ne $divertto || badusage(sprintf(_g("cannot divert file '%s' to itself"), $file));
     $package= ':' unless defined($package);
     for (my $i = 0; $i <= $#contest; $i++) {
         if ($contest[$i] eq $file || $altname[$i] eq $file ||