[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r5329 - branches/OpenDNSSEC-1.2/signer/src/util

Matthijs Mekking matthijs at nlnetlabs.nl
Wed Jul 13 15:59:16 CEST 2011


Author: matthijs
Date: 2011-07-13 15:59:15 +0200 (Wed, 13 Jul 2011)
New Revision: 5329

Modified:
   branches/OpenDNSSEC-1.2/signer/src/util/duration.c
   branches/OpenDNSSEC-1.2/signer/src/util/duration.h
   branches/OpenDNSSEC-1.2/signer/src/util/file.c
Log:
backport from 1.3 (#4)



Modified: branches/OpenDNSSEC-1.2/signer/src/util/duration.c
===================================================================
--- branches/OpenDNSSEC-1.2/signer/src/util/duration.c	2011-07-13 13:58:56 UTC (rev 5328)
+++ branches/OpenDNSSEC-1.2/signer/src/util/duration.c	2011-07-13 13:59:15 UTC (rev 5329)
@@ -35,10 +35,10 @@
 #include "util/log.h"
 #include "util/se_malloc.h"
 
-#include <stdio.h> /* snprintf() */
-#include <stdlib.h> /* atoi(), strtoul(), [arc4]random[_uniform](), getenv() */
-#include <string.h> /* strncat(), strchr() */
-#include <time.h> /* time(), localtime(), strftime() */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
 
 
 /**
@@ -50,6 +50,10 @@
 {
     duration_type* duration = (duration_type*)
         se_malloc(sizeof(duration_type));
+    if (!duration) {
+        se_log_error("cannot create duration: malloc failed");
+        return NULL;
+    }
     duration->years = 0;
     duration->months = 0;
     duration->weeks = 0;
@@ -100,6 +104,7 @@
     return 0;
 }
 
+
 /**
  * Create a duration from string.
  *

Modified: branches/OpenDNSSEC-1.2/signer/src/util/duration.h
===================================================================
--- branches/OpenDNSSEC-1.2/signer/src/util/duration.h	2011-07-13 13:58:56 UTC (rev 5328)
+++ branches/OpenDNSSEC-1.2/signer/src/util/duration.h	2011-07-13 13:59:15 UTC (rev 5329)
@@ -57,7 +57,7 @@
 
 /**
  * Create a new 'instant' duration.
- * \return duration_t* the created duration
+ * \return duration_type* created duration
  *
  */
 duration_type* duration_create(void);
@@ -74,7 +74,7 @@
 /**
  * Create a duration from string.
  * \param[in] str string-format duration
- * \return duration_t* the created duration
+ * \return duration_type* created duration
  *
  */
 duration_type* duration_create_from_string(const char* str);

Modified: branches/OpenDNSSEC-1.2/signer/src/util/file.c
===================================================================
--- branches/OpenDNSSEC-1.2/signer/src/util/file.c	2011-07-13 13:58:56 UTC (rev 5328)
+++ branches/OpenDNSSEC-1.2/signer/src/util/file.c	2011-07-13 13:59:15 UTC (rev 5329)
@@ -130,6 +130,10 @@
 
         if (len_total > 0) {
             openf = (char*) se_malloc(sizeof(char)*(len_total + 1));
+            if (!openf) {
+                se_log_crit("build path failed: malloc failed");
+                return NULL;
+            }
 
             strncpy(openf, file, len_file);
             openf[len_file] = '\0';
@@ -174,6 +178,9 @@
     len_total = len_dir + len_file;
     if (len_total > 0) {
         openf = (char*) se_malloc(sizeof(char)*(len_total + 1));
+        if (!openf) {
+            return NULL;
+        }
         if (dir) {
            strncpy(openf, dir, len_dir);
            openf[len_dir] = '\0';
@@ -344,6 +351,7 @@
 {
     char str[SYSTEM_MAXLEN];
     FILE* fd = NULL;
+    int retval = 0;
 
     se_log_assert(file1);
     se_log_assert(file2);
@@ -353,7 +361,12 @@
         snprintf(str, SYSTEM_MAXLEN, "%s %s %s > /dev/null",
             CP_COMMAND, file1, file2);
         se_log_debug("system call: %s", str);
-        return system(str);
+        retval = system(str);
+        if (retval != 0) {
+            se_log_error("%s failed: return value %i",
+                    CP_COMMAND, retval);
+        }
+        return retval;
     }
     /* no such file */
     return 1;




More information about the Opendnssec-commits mailing list