]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-unsub: fix an issue when the reported subdir of pointer is NULL
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 28 Oct 2021 15:10:00 +0000 (17:10 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 28 Oct 2021 15:10:00 +0000 (17:10 +0200)
src/subscriberfuncs.c

index ea4960e72e5a45540ee8417653e6aae722331caa..c539681e1bc8cb643ed1a52661362559f3a84e59 100644 (file)
@@ -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);
 }