Skip to content

Commit 985b331

Browse files
ethan-thompsonalandekok
authored andcommitted
restore write errno after ftruncate in partial header write path
Signed-off-by: ethan-thompson <ethan.thompson@networkradius.com>
1 parent 697f05c commit 985b331

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/modules/rlm_linelog/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ static void _batch_write(rlm_linelog_file_t *file)
190190
write_error = errno;
191191
if (ret >= 0) {
192192
if (ret < (ssize_t)(header_len)) {
193-
ret = ftruncate(fd, 0);
194-
if (ret < 0) {
193+
if (ftruncate(fd, 0) < 0) {
195194
ERROR("Failed truncating file \"%s\" after partial header write - %s",
196195
file->filename, fr_syserror(errno));
197196
}
197+
errno = write_error;
198198

199199
PERROR("Failed writing header to \"%s\"", file->filename);
200200
goto error;

0 commit comments

Comments
 (0)