소스 검색

dpkg: Print a message instead of asserting on readlink/stat size discrepancy

This will help the user diagnose which file was affected and in
correcting the situation, which in most cases is due to file system
breakage, or non POSIX compliance.

Closes: #639229
Guillem Jover 15 년 전
부모
커밋
5f40ae0644
3개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 0
      debian/changelog
  2. 3 1
      src/archives.c
  3. 5 1
      src/configure.c

+ 2 - 0
debian/changelog

@@ -202,6 +202,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * Change Dpkg::Compression default values depending on the compressor
     used, and as such dpkg-source inherits this functionality.
     Prompted by Timo Juhani Lindfors <timo.lindfors@iki.fi>.
+  * Print an actual error or warning message instead of assert()ing on
+    readlink()/stat() size discrepancies. Closes: #639229
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312

+ 3 - 1
src/archives.c

@@ -830,7 +830,9 @@ tarobject(void *ctx, struct tar_entry *ti)
       r = readlink(fnamevb.buf, symlinkfn.buf, symlinkfn.size);
       if (r < 0)
         ohshite(_("unable to read link `%.255s'"), ti->name);
-      assert(r == stab.st_size);
+      else if (r != stab.st_size)
+        ohshit(_("symbolic link '%.250s' size has changed from %jd to %zd"),
+               fnamevb.buf, stab.st_size, r);
       varbuf_trunc(&symlinkfn, r);
       varbuf_end_str(&symlinkfn);
       if (symlink(symlinkfn.buf,fnametmpvb.buf))

+ 5 - 1
src/configure.c

@@ -418,8 +418,12 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in)
 				          " (= '%s'): %s"),
 				        pkg->name, in, result->buf, strerror(errno));
 				return -1;
+			} else if (r != stab.st_size) {
+				warning(_("symbolic link '%.250s' size has "
+				          "changed from %jd to %zd"),
+				        result->buf, stab.st_size, r);
+				return -1;
 			}
-			assert(r == stab.st_size); /* XXX: debug */
 			varbuf_trunc(&target, r);
 			varbuf_end_str(&target);