]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: dont create log file for fuzz builds
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Mar 2021 08:03:46 +0000 (09:03 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Mar 2021 08:20:56 +0000 (09:20 +0100)
Fixes: #3730
Fixes: https://github.com/google/oss-fuzz/issues/5509
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/log.c

index 92b526689488db3048e95da7f7dd39205ff02cb6..e1473603a629b2deea5bce970da79759dbe549e4 100644 (file)
@@ -513,8 +513,9 @@ static int build_dir(const char *name)
 
 static int log_open(const char *name)
 {
+       int newfd = -EBADF;
+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
        __do_close int fd = -EBADF;
-       int newfd;
 
        fd = lxc_unpriv(open(name, O_CREAT | O_WRONLY | O_APPEND | O_CLOEXEC, 0660));
        if (fd < 0)
@@ -526,7 +527,7 @@ static int log_open(const char *name)
        newfd = fcntl(fd, F_DUPFD_CLOEXEC, STDERR_FILENO);
        if (newfd < 0)
                return log_error_errno(-errno, errno, "Failed to dup log fd %d", fd);
-
+#endif /* !FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
        return newfd;
 }
 
@@ -821,7 +822,6 @@ int lxc_log_set_file(int *fd, const char *fname)
        *fd = log_open(fname);
        if (*fd < 0)
                return -errno;
-
        return 0;
 }