Procházet zdrojové kódy

Fix preinst to not fail on read on broken alternatives status files

The internal structure of alternatives status file is line based.
Empty lines end each section. read call can fail if the file is truncated
at some unexpected point. Thus protect all read calls with "|| continue"
or "|| break" depending on the case.
Raphael Hertzog před 17 roky
rodič
revize
b866c02dfc
2 změnil soubory, kde provedl 6 přidání a 4 odebrání
  1. 2 0
      debian/changelog
  2. 4 4
      debian/dpkg.preinst

+ 2 - 0
debian/changelog

@@ -32,6 +32,8 @@ dpkg (1.15.4) UNRELEASED; urgency=low
     See http://wiki.debian.org/Transitions/DpkgToGnuInstallInfo for details.
   * Fix dpkg's preinst in case /var/lib/dpkg/alternatives contains unexpected
     sub-directories. Closes: #535138
+    And also when one of the file doesn't contain correct alternatives
+    information (improper number of lines). Closes: #537558
   * Upgrade Standards-Version to 3.8.2 (no changes).
   * Update deb-substvars(5) to list fields that do not support substvars.
     Closes: #535353

+ 4 - 4
debian/dpkg.preinst

@@ -36,10 +36,10 @@ kill_bad_alternatives () {
             continue
         fi
         {
-            read mode
-            read mainlink
+            read mode || continue
+            read mainlink || continue
             while true; do
-                read slave
+                read slave || break
                 if [ "$slave" = "" ]; then
                     break
                 fi
@@ -47,7 +47,7 @@ kill_bad_alternatives () {
                     echo "Removing conflicting master alternative $slave (it is slave of $(basename $alt))..."
                     rm -f "$ALTDIR/$slave"
                 fi
-                read slavelink
+                read slavelink || break
             done
         } <$alt
     done