]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Combine openat and fchmod
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 31 Oct 2021 15:11:06 +0000 (11:11 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 31 Oct 2021 15:11:06 +0000 (11:11 -0400)
src/bin/unit_test_attribute.c

index 6b00f8acfcf1555b5754a7888b009c3794f9863e..cde6c2a63a085537ace15498eb85b148f54459ac 100644 (file)
@@ -424,16 +424,8 @@ static inline int dump_fuzzer_data(int fd_dir, char const *text, uint8_t const *
        fr_base64_encode_nstd(&FR_SBUFF_OUT(digest_str, sizeof(digest_str)), &FR_DBUFF_TMP(digest, sizeof(digest)),
                              false, fr_base64_url_alphabet_encode);
 
-       file_fd = openat(fd_dir, digest_str, O_RDWR | O_CREAT | O_TRUNC);
-       if (file_fd < 0) {
-               fr_strerror_printf("Failed creating corpus input file \"%s\": %s", digest_str, fr_syserror(errno));
-               return -1;
-       }
-
-       if (fchmod(file_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) < 0) {
-               fr_strerror_printf("Failed setting permissions for \"%s\": %s", digest_str, fr_syserror(errno));
-               return -1;
-       }
+       file_fd = openat(fd_dir, digest_str, O_RDWR | O_CREAT | O_TRUNC,
+                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 
        if (write(file_fd, data, data_len) != (ssize_t)data_len) {
                fr_strerror_printf("Failed writing to corpus input file \"%s\": %s", digest_str, fr_syserror(errno));