Kaynağa Gözat

Abort on unrecoverable fatal errors instead of continuing execution

The code handling onerr_abort is broken, and parts of the recovery code
assumed the code would not reach them again as the program should have
existed already.

Closes: #497041, #499070
Guillem Jover 17 yıl önce
ebeveyn
işleme
22f1d67269
3 değiştirilmiş dosya ile 22 ekleme ve 1 silme
  1. 5 0
      ChangeLog
  2. 4 0
      debian/changelog
  3. 13 1
      lib/ehandle.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-11-14  Guillem Jover  <guillem@debian.org>
+
+	* lib/ehandle.c (run_error_handler): In case of onerr_abort print an
+	error message and exit, otherwise longjmp.
+
 2008-11-14  Guillem Jover  <guillem@debian.org>
 
 	* src/main.h (abort_processing): New variable declaration.

+ 4 - 0
debian/changelog

@@ -11,6 +11,10 @@ dpkg (1.14.23) UNRELEASED; urgency=low
   [ Guillem Jover ]
   * Untangle fatal abort condition from the “too many errors” one in the
     archives and packages processing loop.
+  * Abort on unrecoverable fatal errors instead of continuing execution, as
+    the recovery code assumed the execution would not be reaching it again
+    and some times bogus update files were created either with incompletely
+    written content or with '#padding' lines. Closes: #497041, #499070
 
   [ Updated dpkg translations ]
   * Catalan (Jordi Mallach).

+ 13 - 1
lib/ehandle.c

@@ -75,7 +75,19 @@ static void run_error_handler(void) NONRETURNING;
 static void
 run_error_handler(void)
 {
-  longjmp(*econtext->jbufp, 1);
+  if (onerr_abort) {
+    /* We arrived here due to a fatal error from which we cannot recover,
+     * and trying to do so would most probably get us here again. That's
+     * why we will not try to do any error unwinding either. We'll just
+     * abort. Hopefully the user can fix the situation (out of disk, out
+     * of memory, etc).
+     */
+    fprintf(stderr, _("%s: unrecoverable fatal error, aborting:\n %s\n"),
+            thisname, errmsg);
+    exit(2);
+  } else {
+    longjmp(*econtext->jbufp, 1);
+  }
 }
 
 void push_error_handler(jmp_buf *jbufp,