Procházet zdrojové kódy

Handle errors properly in do_check

Wichert Akkerman před 24 roky
rodič
revize
5afbd2ec70
3 změnil soubory, kde provedl 15 přidání a 0 odebrání
  1. 3 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 11 0
      utils/md5sum.c

+ 3 - 0
ChangeLog

@@ -1,3 +1,6 @@
+Thu Jan  3 15:20:25 CET 2002 Wichert Akkerman <wakkerma@debian.org>
+
+  * utils/md5sum.c: add error handling to do_check
 Wed Jan  2 16:08:02 CET 2002 Wichert Akkerman <wakkerma@debian.org>
 
   * scripts/dpkg-source.pl: Update default ignore expression to also

+ 1 - 0
debian/changelog

@@ -66,6 +66,7 @@ dpkg (1.10) unstable; urgency=low
     dpkg-checkbuilddeps
   * Update default ignore expression in dpkg-source to also match *~ and
     *.swp in subdirs. Closes: Bug#127458
+  * Handle errors when verifying md5sums. Closes: Bug#102367
 
  -- Wichert Akkerman <wakkerma@debian.org>  Mon, 20 Aug 2001 14:54:38 +0200
 

+ 11 - 0
utils/md5sum.c

@@ -239,6 +239,7 @@ do_check(FILE *chkf)
 	char filename[256];
 	FILE *fp;
 	size_t flen = 14;
+	jmp_buf ejbuf;
 
 	while ((rc = get_md5_line(chkf, chk_digest, filename)) >= 0) {
 		if (rc == 0)	/* not an md5 line */
@@ -248,6 +249,12 @@ do_check(FILE *chkf)
 				flen = strlen(filename);
 			fprintf(stderr, "%-*s ", (int)flen, filename);
 		}
+		if (setjmp(ejbuf)) {
+			error_unwind(ehflag_bombout);
+			ex = 2;
+			continue;
+		}
+		push_error_handler(&ejbuf, print_md5sum_error, filename);
 		if (bin_mode || rc == 2)
 			fp = fopen(filename, FOPRBIN);
 		else
@@ -257,13 +264,17 @@ do_check(FILE *chkf)
 			ex = 2;
 			continue;
 		}
+		push_cleanup(cu_closefile,ehflag_bombout, 0,0, 1,(void*)fp);
 		if (mdfile(fileno(fp), &file_digest)) {
 			fprintf(stderr, _("%s: error reading %s\n"), progname, filename);
 			ex = 2;
 			fclose(fp);
 			continue;
 		}
+		pop_cleanup(ehflag_normaltidy); /* fd= fopen() */
 		fclose(fp);
+		set_error_display(0, 0);
+		error_unwind(ehflag_normaltidy);
 		if (memcmp(chk_digest, file_digest, 32) != 0) {
 			if (verbose)
 				fprintf(stderr, _("FAILED\n"));