[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3750 - in trunk/OpenDNSSEC/signer/src: daemon signer util

Matthijs Mekking matthijs at nlnetlabs.nl
Thu Aug 12 14:14:58 CEST 2010


Author: matthijs
Date: 2010-08-12 14:14:58 +0200 (Thu, 12 Aug 2010)
New Revision: 3750

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
   trunk/OpenDNSSEC/signer/src/daemon/engine.c
   trunk/OpenDNSSEC/signer/src/signer/tools.c
   trunk/OpenDNSSEC/signer/src/util/file.c
Log:
more coverity stuff



Modified: trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-12 11:04:20 UTC (rev 3749)
+++ trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-12 12:14:58 UTC (rev 3750)
@@ -305,7 +305,6 @@
 static void
 cmdhandler_handle_cmd_queue(int sockfd, cmdhandler_type* cmdc)
 {
-    char* taskstr = NULL;
     char* strtime = NULL;
     char buf[ODS_SE_MAXLINE];
     size_t i = 0;
@@ -669,7 +668,9 @@
     }
 
     /* no suprises */
-    unlink(filename);
+    if (filename) {
+        unlink(filename);
+    }
     bzero(&servaddr, sizeof(servaddr));
     servaddr.sun_family = AF_UNIX;
     strncpy(servaddr.sun_path, filename, sizeof(servaddr.sun_path) - 1);

Modified: trunk/OpenDNSSEC/signer/src/daemon/engine.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-08-12 11:04:20 UTC (rev 3749)
+++ trunk/OpenDNSSEC/signer/src/daemon/engine.c	2010-08-12 12:14:58 UTC (rev 3750)
@@ -511,7 +511,7 @@
         }
 
         if (single_run) {
-                engine->need_to_exit = 1;
+           engine->need_to_exit = 1;
         } else if (engine->signal == SIGNAL_RUN) {
            se_log_debug("engine taking a break");
            lock_basic_sleep(&engine->signal_cond, &engine->signal_lock, 3600);

Modified: trunk/OpenDNSSEC/signer/src/signer/tools.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/tools.c	2010-08-12 11:04:20 UTC (rev 3749)
+++ trunk/OpenDNSSEC/signer/src/signer/tools.c	2010-08-12 12:14:58 UTC (rev 3750)
@@ -210,10 +210,12 @@
 
         se_log_debug("system call: %s", str);
         error = system(str);
-        if (!error) {
-            unlink(finalized);
+        if (finalized) {
+            if (!error) {
+                unlink(finalized);
+            }
+            se_free((void*)finalized);
         }
-        se_free((void*)finalized);
     }
     return error;
 }

Modified: trunk/OpenDNSSEC/signer/src/util/file.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/file.c	2010-08-12 11:04:20 UTC (rev 3749)
+++ trunk/OpenDNSSEC/signer/src/util/file.c	2010-08-12 12:14:58 UTC (rev 3750)
@@ -122,23 +122,27 @@
 
     if (file) {
         len_file = strlen(file);
-    }
-    if (suffix) {
-        len_suffix = strlen(suffix);
-    }
-    len_total = len_suffix + len_file;
-    if (dir) {
-        len_total++;
-    }
-    if (len_total > 0) {
-        openf = (char*) se_malloc(sizeof(char)*(len_total + 1));
-        strncpy(openf, file, len_file);
-        openf[len_file] = '\0';
-        strncat(openf, suffix, len_suffix);
+        if (suffix) {
+            len_suffix = strlen(suffix);
+        }
+        len_total = len_suffix + len_file;
         if (dir) {
-            strncat(openf, "/", 1);
+            len_total++;
         }
-        openf[len_total] = '\0';
+
+        if (len_total > 0) {
+            openf = (char*) se_malloc(sizeof(char)*(len_total + 1));
+
+            strncpy(openf, file, len_file);
+            openf[len_file] = '\0';
+            if (suffix) {
+                strncat(openf, suffix, len_suffix);
+            }
+            if (dir) {
+                strncat(openf, "/", 1);
+            }
+            openf[len_total] = '\0';
+        }
     }
 
     return openf;
@@ -175,8 +179,10 @@
         if (dir) {
            strncpy(openf, dir, len_dir);
            openf[len_dir] = '\0';
-           strncat(openf, file, len_file);
-        } else {
+           if (file) {
+               strncat(openf, file, len_file);
+           }
+        } else if (file) {
            strncpy(openf, file, len_file);
         }
         openf[len_total] = '\0';
@@ -336,9 +342,14 @@
 {
     char* dir = NULL;
 
+    if (!file) {
+        se_log_warning("no filename given for chown()");
+        return;
+    }
+
     if (!getdir) {
         se_log_debug("create and chown directory %s [user %ld] [group %ld]",
-           file?file:"(null)", (signed long) uid, (signed long) gid);
+           file, (signed long) uid, (signed long) gid);
         if (chown(file, uid, gid) != 0) {
             se_log_error("chown() for %s failed: %s", file?file:"(null)",
                 strerror(errno));
@@ -347,12 +358,12 @@
         se_log_debug("create and chown directory %s [user %ld] [group %ld]",
            dir, (signed long) uid, (signed long) gid);
         if (chown(dir, uid, gid) != 0) {
-            se_log_error("chown() for %s failed: %s", dir?dir:"(null)",
+            se_log_error("chown() for %s failed: %s", dir,
                 strerror(errno));
         }
         se_free((void*) dir);
     } else {
-        se_log_warning("use of relative path: %s", file?file:"(null)");
+        se_log_warning("use of relative path: %s", file);
     }
     return;
 }




More information about the Opendnssec-commits mailing list