]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
restore write errno after ftruncate in partial header write path
authorethan-thompson <ethan.thompson@networkradius.com>
Mon, 16 Mar 2026 16:21:51 +0000 (12:21 -0400)
committerAlan DeKok <aland@freeradius.org>
Mon, 16 Mar 2026 20:36:43 +0000 (16:36 -0400)
Signed-off-by: ethan-thompson <ethan.thompson@networkradius.com>
src/modules/rlm_linelog/file.c

index e63c76db425c82ee78a14214cb4caeeb33e918d2..625db65c04c4680bd91d7d77285c50717ed65659 100644 (file)
@@ -190,11 +190,11 @@ static void _batch_write(rlm_linelog_file_t *file)
        write_error = errno;
        if (ret >= 0) {
                if (ret < (ssize_t)(header_len)) {
-                       ret = ftruncate(fd, 0);
-                       if (ret < 0) {
+                       if (ftruncate(fd, 0) < 0) {
                                ERROR("Failed truncating file \"%s\" after partial header write - %s",
                                      file->filename, fr_syserror(errno));
                        }
+                       errno = write_error;
 
                        PERROR("Failed writing header to \"%s\"", file->filename);
                        goto error;