[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r4137 - trunk/OpenDNSSEC/signer/src/util

Matthijs Mekking matthijs at nlnetlabs.nl
Mon Oct 25 14:59:12 CEST 2010


Author: matthijs
Date: 2010-10-25 14:59:12 +0200 (Mon, 25 Oct 2010)
New Revision: 4137

Modified:
   trunk/OpenDNSSEC/signer/src/util/file.c
Log:
check if file exists before copying



Modified: trunk/OpenDNSSEC/signer/src/util/file.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/file.c	2010-10-25 12:13:35 UTC (rev 4136)
+++ trunk/OpenDNSSEC/signer/src/util/file.c	2010-10-25 12:59:12 UTC (rev 4137)
@@ -343,14 +343,20 @@
 se_file_copy(const char* file1, const char* file2)
 {
     char str[SYSTEM_MAXLEN];
+    FILE* fd = NULL;
 
     se_log_assert(file1);
     se_log_assert(file2);
 
-    snprintf(str, SYSTEM_MAXLEN, "%s %s %s > /dev/null",
-        CP_COMMAND, file1, file2);
-    se_log_debug("system call: %s", str);
-    return system(str);
+    if ((fd = se_fopen(file1, NULL, "r")) != NULL) {
+        se_fclose(fd);
+        snprintf(str, SYSTEM_MAXLEN, "%s %s %s > /dev/null",
+            CP_COMMAND, file1, file2);
+        se_log_debug("system call: %s", str);
+        return system(str);
+    }
+    /* no such file */
+    return 1;
 }
 
 /**




More information about the Opendnssec-commits mailing list