]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
fix TOCTOU by using O_NOFOLLOW which also simplifies code
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 27 Mar 2026 07:13:01 +0000 (08:13 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 27 Mar 2026 07:13:01 +0000 (08:13 +0100)
src/mlmmj.c

index c88cf2713048339d09acd3515b69eb60669aa89b..5559d8a073e23bb28eb415499016a2f85be93161 100644 (file)
@@ -501,13 +501,6 @@ bouncemail(int listfd, const char *theaddress, const char *identifier)
                return (BOUNCE_OK);
        }
 
-       if(fstatat(bdfd, address, &st, AT_SYMLINK_NOFOLLOW) == 0) {
-               if(S_ISLNK(st.st_mode)) {
-                       log_error(LOG_ARGS, "bounce/%s is a symbolic link", address);
-                       free(address);
-                       return (BOUNCE_FAIL);
-               }
-       }
        *tmp = '@';
        if (is_subbed(listfd, address, 0) == SUB_NONE) {
                log_error(LOG_ARGS, "%s is bouncing but not subscribed?",
@@ -516,7 +509,7 @@ bouncemail(int listfd, const char *theaddress, const char *identifier)
                return (BOUNCE_OK);
        }
        *tmp = '=';
-       bfd = openat(bdfd, address, O_WRONLY|O_APPEND|O_CREAT, S_IRUSR|S_IWUSR);
+       bfd = openat(bdfd, address, O_WRONLY|O_APPEND|O_CREAT|O_NOFOLLOW, S_IRUSR|S_IWUSR);
        close(bdfd);
        if (bfd == -1) {
                log_error(LOG_ARGS, "Cound not open(bounce/%s)", address);