mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 23:25:38 +00:00
If the rename failed in isc_file_renameunique() unlink the temporary file.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: file.c,v 1.23 2000/10/03 05:45:39 marka Exp $ */
|
/* $Id: file.c,v 1.24 2000/10/07 06:55:01 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -155,6 +155,7 @@ isc_file_renameunique(const char *file, char *templet) {
|
|||||||
int fd = -1;
|
int fd = -1;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
isc_result_t result = ISC_R_SUCCESS;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
|
struct stat stats;
|
||||||
|
|
||||||
fd = mkstemp(templet);
|
fd = mkstemp(templet);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
@@ -162,8 +163,10 @@ isc_file_renameunique(const char *file, char *templet) {
|
|||||||
}
|
}
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
res = rename(file, templet);
|
res = rename(file, templet);
|
||||||
if (res != 0)
|
if (res != 0) {
|
||||||
|
(void)unlink(templet);
|
||||||
result = isc__errno2result(errno);
|
result = isc__errno2result(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Reference in New Issue
Block a user