From 43c42496d0bc3bcbd12def7fff8f0935b1de3dc3 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 10 May 2018 15:04:39 +0200 Subject: 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 Bisected-by: Sven Joachim --- src/divertcmd.c | 6 +++--- 1 file 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) -- cgit v1.2.3