From: Baptiste Daroussin Date: Thu, 28 Oct 2021 15:10:00 +0000 (+0200) Subject: mlmmj-unsub: fix an issue when the reported subdir of pointer is NULL X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9add22717c98f73178532e7964bb5f64683c7beb;p=thirdparty%2Fmlmmj.git mlmmj-unsub: fix an issue when the reported subdir of pointer is NULL --- diff --git a/src/subscriberfuncs.c b/src/subscriberfuncs.c index ea4960e7..c539681e 100644 --- a/src/subscriberfuncs.c +++ b/src/subscriberfuncs.c @@ -182,22 +182,26 @@ int open_subscriber_directory(struct mlmmj_list *list, enum subtype typesub, const char **subdir) { int fd; + const char *dir; + switch (typesub) { default: case SUB_NORMAL: - *subdir = "subscribers.d"; + dir = "subscribers.d"; break; case SUB_DIGEST: - *subdir = "digesters.d"; + dir = "digesters.d"; break; case SUB_NOMAIL: - *subdir = "nomailsubs.d"; + dir = "nomailsubs.d"; break; } - fd = openat(list->fd, *subdir, O_DIRECTORY|O_CLOEXEC); + if (subdir != NULL) + *subdir = dir; + fd = openat(list->fd, dir, O_DIRECTORY|O_CLOEXEC); if (fd == -1) - err(EXIT_FAILURE, "Unable to open %s/%s", list->dir, *subdir); + err(EXIT_FAILURE, "Unable to open %s/%s", list->dir, dir); return (fd); }