Skip to content

Commit 81ead9e

Browse files
ncopatridge
authored andcommitted
Fix use-after-free in generator
full_fname() will free the return value in the next call so we need to duplicate it before passing it to rsyserr. Fixes: #704
1 parent 996af4a commit 81ead9e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

generator.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -2041,8 +2041,12 @@ int atomic_create(struct file_struct *file, char *fname, const char *slnk, const
20412041

20422042
if (!skip_atomic) {
20432043
if (do_rename(tmpname, fname) < 0) {
2044+
char *full_tmpname = strdup(full_fname(tmpname));
2045+
if (full_tmpname == NULL)
2046+
out_of_memory("atomic_create");
20442047
rsyserr(FERROR_XFER, errno, "rename %s -> \"%s\" failed",
2045-
full_fname(tmpname), full_fname(fname));
2048+
full_tmpname, full_fname(fname));
2049+
free(full_tmpname);
20462050
do_unlink(tmpname);
20472051
return 0;
20482052
}

0 commit comments

Comments
 (0)