[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

2 small patches



Hi Guillem,

I have these two small patches sitting in my pu/master. One helps to fail
earlier when a .list file is not a regular file (usually due to filesystem
corruption, see http://bugs.launchpad.net/bugs/369898) and the other fixes
ensure_package_clientdata() to initializes all fields (cleaner API wise
but makes no practical difference since in the few cases where that field
was used it was already manually reset).

Any objection to those changes ? 

(For the first change, since we already do a fstat() adding the check
has almost no cost.)

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/liberation/
>From 50e36c2931b5c806b006afe955993244b43a1c3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hertzog@debian.org>
Date: Sat, 26 Nov 2011 10:03:44 +0100
Subject: [PATCH 1/2] dpkg: fix ensure_package_clientdata() to initialize all
 attributes

---
 src/filesdb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/filesdb.c b/src/filesdb.c
index f5cd1e8..0985d07 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -162,6 +162,7 @@ ensure_package_clientdata(struct pkginfo *pkg)
   pkg->clientdata->color = white;
   pkg->clientdata->fileslistvalid = false;
   pkg->clientdata->files = NULL;
+  pkg->clientdata->replacingfilesandsaid = 0;
   pkg->clientdata->listfile_phys_offs = 0;
   pkg->clientdata->trigprocdeferred = NULL;
 }
-- 
1.7.7.3

>From af09a71c3c4eb8e9a9e8dcc5587c34dd7e8c954f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hertzog@debian.org>
Date: Sat, 26 Nov 2011 10:26:19 +0100
Subject: [PATCH 2/2] dpkg: error out if a .list file is not a regular file

LP: #369898
---
 debian/changelog |    1 +
 src/filesdb.c    |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 37a52ef..dc38f99 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -57,6 +57,7 @@ dpkg (1.16.2) UNRELEASED; urgency=low
     dependencies for another architecture. This is really basic for now since
     it assumes all build dependencies must be satisfied on the listed
     architecture. Closes: #648180 Thanks to Colin Watson for the patch.
+  * Errors out if a .list file is not a regular file. LP: #369898
 
   [ Jonathan Nieder ]
   * Bump po4a version in Build-Depends to 0.41, since earlier versions do
diff --git a/src/filesdb.c b/src/filesdb.c
index 0985d07..bc7b895 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -325,6 +325,9 @@ ensure_packagefiles_available(struct pkginfo *pkg)
      ohshite(_("unable to stat files list file for package '%.250s'"),
              pkg->set->name);
 
+  if (!S_ISREG(stat_buf.st_mode))
+    ohshit(_("database is corrupted: %s is not a regular file"), filelistfile);
+
    if (stat_buf.st_size) {
      loaded_list = nfmalloc(stat_buf.st_size);
      loaded_list_end = loaded_list + stat_buf.st_size;
-- 
1.7.7.3


Reply to: