summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-05-10 15:04:39 +0200
committerGuillem Jover <guillem@debian.org>2018-05-10 15:08:02 +0200
commit43c42496d0bc3bcbd12def7fff8f0935b1de3dc3 (patch)
treec5732e79b24a2b9de554dd9033dd3e849a1850e3
parentdf0a86de45006f9f2b2980a0ad2e81640271a685 (diff)
downloaddpkg-43c42496d0bc3bcbd12def7fff8f0935b1de3dc3.tar.gz
dpkg-divert: Do not assume that diversions are always present
Several code paths assumed that the fsys nodes were only present when they contained diversions, and no other nodes would be present, thus did not make sure to check whether the divert struct members were valid. With the switch to a single fsys underlying implementation now triggers can vivify namenodes in the hash, so we need to check whether the members are valid all the time. Fixes: commit 2d7566140335d5338e5a98278d4df762936f67f4 Reported-by: Sven Joachim <svenjoac@gmx.de> Bisected-by: Sven Joachim <svenjoac@gmx.de>
-rw-r--r--src/divertcmd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/divertcmd.c b/src/divertcmd.c
index e7bb5ad48..170c9e93e 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -685,7 +685,7 @@ diversion_list(const char *const *argv)
struct diversion *altname;
const char *pkgname;
- if (contest->useinstead == NULL)
+ if (contest == NULL || contest->useinstead == NULL)
continue;
altname = contest->useinstead->divert;
@@ -722,7 +722,7 @@ diversion_truename(const char *const *argv)
namenode = findnamenode(filename, fnn_nonew);
/* Print the given name if file is not diverted. */
- if (namenode && namenode->divert->useinstead)
+ if (namenode && namenode->divert && namenode->divert->useinstead)
printf("%s\n", namenode->divert->useinstead->name);
else
printf("%s\n", filename);
@@ -744,7 +744,7 @@ diversion_listpackage(const char *const *argv)
namenode = findnamenode(filename, fnn_nonew);
/* Print nothing if file is not diverted. */
- if (namenode == NULL)
+ if (namenode == NULL || namenode->divert == NULL)
return 0;
if (namenode->divert->pkgset == NULL)