Date: | Thu, 25 Sep 2014 08:02:44 -0700 |
From: | Tsu-Phong Wu <tsu-phong.wu@oracle.com> |
To: | krb5-bugs@mit.edu |
Subject: | rename() failure in src/util/profile/prof_file.c:write_data_to_file() |
CC: | "WU,TSU-PHONG" <tsu-phong.wu@oracle.com> |
Hi,
Like to report a bug with simple fix below:
unlink(old_file);
if (make_hard_link(outfile, old_file) == 0) {
/* Okay, got the hard link. Yay. Now we've got our
backup version, so just put the new version in
place. */
if (rename(new_file, outfile)) {
/* Weird, the rename didn't work. But the old version
should still be in place, so no special cleanup is
needed. */
<<<<<
unlink(old_file); <<<<< In case of rename() failure,
outfile should be fine.
<<<<< But old_file is extra from above make_hard_link(), and should be
removed.
retval = errno;
goto errout;
}
} else if (errno == ENOENT && can_create) {
Like to report a bug with simple fix below:
unlink(old_file);
if (make_hard_link(outfile, old_file) == 0) {
/* Okay, got the hard link. Yay. Now we've got our
backup version, so just put the new version in
place. */
if (rename(new_file, outfile)) {
/* Weird, the rename didn't work. But the old version
should still be in place, so no special cleanup is
needed. */
<<<<<
unlink(old_file); <<<<< In case of rename() failure,
outfile should be fine.
<<<<< But old_file is extra from above make_hard_link(), and should be
removed.
retval = errno;
goto errout;
}
} else if (errno == ENOENT && can_create) {