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

Matthijs Mekking matthijs at nlnetlabs.nl
Thu Aug 12 12:33:37 CEST 2010


Author: matthijs
Date: 2010-08-12 12:33:37 +0200 (Thu, 12 Aug 2010)
New Revision: 3748

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/cfg.c
   trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
   trunk/OpenDNSSEC/signer/src/daemon/worker.c
   trunk/OpenDNSSEC/signer/src/ods-signer.c
   trunk/OpenDNSSEC/signer/src/parser/zonelistparser.c
   trunk/OpenDNSSEC/signer/src/scheduler/task.c
   trunk/OpenDNSSEC/signer/src/signer/domain.c
   trunk/OpenDNSSEC/signer/src/signer/rrset.c
   trunk/OpenDNSSEC/signer/src/signer/zonedata.c
   trunk/OpenDNSSEC/signer/src/tools/zone_fetcher.c
   trunk/OpenDNSSEC/signer/src/util/duration.c
   trunk/OpenDNSSEC/signer/src/util/file.c
   trunk/OpenDNSSEC/signer/src/util/log.c
   trunk/OpenDNSSEC/signer/src/util/privdrop.c
   trunk/OpenDNSSEC/signer/src/util/se_malloc.c
Log:
make coverity more happy



Modified: trunk/OpenDNSSEC/signer/src/daemon/cfg.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/cfg.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/daemon/cfg.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -59,6 +59,7 @@
     /* check syntax (slows down parsing configuration file) */
     if (parse_file_check(cfgfile, rngfile) != 0) {
         se_log_error("unable to parse cfgfile %s", cfgfile?cfgfile:"(null)");
+        se_free((void*) ecfg);
         return NULL;
     }
 

Modified: trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/daemon/cmdhandler.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -335,7 +335,7 @@
         for (i=0; i < ODS_SE_MAXLINE; i++) {
             buf[i] = 0;
         }
-        taskstr = task2str(task, (char*) &buf[0]);
+        (void)task2str(task, (char*) &buf[0]);
         se_writen(sockfd, buf, strlen(buf));
         node = ldns_rbtree_next(node);
     }

Modified: trunk/OpenDNSSEC/signer/src/daemon/worker.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/worker.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/daemon/worker.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -104,6 +104,9 @@
                 lock_basic_lock(&worker->tasklist->tasklist_lock);
                 zone->in_progress = 0;
                 task = tasklist_schedule_task(worker->tasklist, task, 1);
+                if (!task) {
+                    se_log_error("failed to schedule task");
+                }
                 lock_basic_unlock(&worker->tasklist->tasklist_lock);
             }
 

Modified: trunk/OpenDNSSEC/signer/src/ods-signer.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/ods-signer.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/ods-signer.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -138,8 +138,12 @@
             }
 
             /* socket is readable */
-            if ((n = read(sockfd, buf, ODS_SE_MAXLINE)) == 0) {
-                if (stdineof == 1) {
+            if ((n = read(sockfd, buf, ODS_SE_MAXLINE)) <= 0) {
+                if (n < 0) {
+                    /* error occurred */
+                    fprintf(stderr, "error: %s\n", strerror(errno));
+                    exit(1);
+                } else if (stdineof == 1) {
                     /* normal termination */
                     return;
                 } else {
@@ -155,6 +159,7 @@
                 if (n > SE_CLI_CMDLEN) {
                     ret = (int) write(fileno(stdout), buf, n-SE_CLI_CMDLEN);
                 }
+                buf[(n-SE_CLI_CMDLEN)] = '\0';
                 cmd_response = 1;
                 ret = 1;
             } else {
@@ -319,7 +324,7 @@
     }
     if (argc > 1) {
         cmd = (char*) se_calloc(options_size+2,sizeof(char));
-        (void)strncpy(cmd, "", 0);
+        (void)strncpy(cmd, "", 1);
         for (c = 1; c < argc; c++) {
             (void)strncat(cmd, options[c], strlen(options[c]));
             (void)strncat(cmd, " ", 1);

Modified: trunk/OpenDNSSEC/signer/src/parser/zonelistparser.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/parser/zonelistparser.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/parser/zonelistparser.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -198,7 +198,7 @@
             }
             if (doc == NULL || xpathCtx == NULL) {
                 se_log_error("unable to read zone %s; skipping",
-                   zone_name?zone_name:"(null)");
+                   zone_name);
                 se_free((void*) zone_name);
                 ret = xmlTextReaderRead(reader);
                 se_free((void*) tag_name);

Modified: trunk/OpenDNSSEC/signer/src/scheduler/task.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/scheduler/task.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/scheduler/task.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -176,9 +176,6 @@
     char* strtask = NULL;
 
     se_log_assert(task);
-    if (!buftask) {
-        strtask = (char*) se_calloc(ODS_SE_MAXLINE, sizeof(char));
-    }
 
     if (task) {
         if (task->flush) {
@@ -195,6 +192,7 @@
                 task->who?task->who:"(null)");
             return buftask;
         } else {
+            strtask = (char*) se_calloc(ODS_SE_MAXLINE, sizeof(char));
             snprintf(strtask, ODS_SE_MAXLINE, "On %s I will %s zone %s\n",
                 strtime?strtime:"(null)", taskid2str(task->what),
                 task->who?task->who:"(null)");

Modified: trunk/OpenDNSSEC/signer/src/signer/domain.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/domain.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/signer/domain.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -255,6 +255,9 @@
             /* delete memory of RRsets if no RRs exist */
             if (rrset_count_rr(rrset) <= 0) {
                 rrset = domain_del_rrset(domain, rrset);
+                if (rrset) {
+                    se_log_error("failed to delete obsoleted RRset");
+                }
             }
         }
         domain->internal_serial = serial;
@@ -743,8 +746,10 @@
         rrset_cleanup(rrset);
         node = ldns_rbtree_next(node);
     }
-    se_rbnode_free(rrset_tree->root);
-    ldns_rbtree_free(rrset_tree);
+    if (rrset_tree) {
+        se_rbnode_free(rrset_tree->root);
+        ldns_rbtree_free(rrset_tree);
+    }
     return;
 }
 

Modified: trunk/OpenDNSSEC/signer/src/signer/rrset.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/rrset.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/signer/rrset.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -419,8 +419,8 @@
                 "expiration=%u)", rrset->rr_type, refresh, expiration);
             rrset_log_rr(rrs->rr, "*RRSIG", 5);
             *reusedsigs += 1;
+            prev_rrs = rrs;
         }
-        prev_rrs = rrs;
         rrs = rrs->next;
     }
     return 0;

Modified: trunk/OpenDNSSEC/signer/src/signer/zonedata.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/signer/zonedata.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/signer/zonedata.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -191,7 +191,7 @@
         if (!prev_node || prev_node == LDNS_RBTREE_NULL) {
             prev_node = ldns_rbtree_last(zd->nsec3_domains);
         }
-        if (!prev_node || prev_node == LDNS_RBTREE_NULL) {
+        if (prev_node && prev_node != LDNS_RBTREE_NULL) {
             prev_domain = (domain_type*) prev_node->data;
         }
         if (prev_domain) {
@@ -330,10 +330,14 @@
     se_log_assert(domain);
     str = ldns_rdf2str(domain->name);
     se_log_debug("-DD %s", str?str:"(null)");
-    se_free((void*) str);
     if (domain->nsec3) {
         nsec3_domain = zonedata_del_domain_nsec3(zd, domain->nsec3);
+        if (nsec3_domain) {
+            se_log_error("failed to delete corresponding NSEC3 domain, "
+                "deleting domain %s", str?str:"(null)");
+        }
     }
+    se_free((void*) str);
     return zonedata_domain_delete(zd->domains, domain);
 }
 
@@ -831,10 +835,16 @@
              domain->domain_status != DOMAIN_STATUS_ENT_GLUE)) {
             parent = domain->parent;
             domain = zonedata_del_domain(zd, domain);
+            if (domain) {
+                se_log_error("failed to delete obsoleted domain");
+            }
             while (parent && domain_count_rrset(parent) <= 0) {
                 domain = parent;
                 parent = domain->parent;
                 domain = zonedata_del_domain(zd, domain);
+                if (domain) {
+                    se_log_error("failed to delete obsoleted domain");
+                }
             }
         }
     }
@@ -938,8 +948,10 @@
         domain_cleanup(domain);
         node = ldns_rbtree_next(node);
     }
-    se_rbnode_free(domain_tree->root);
-    ldns_rbtree_free(domain_tree);
+    if (domain_tree) {
+        se_rbnode_free(domain_tree->root);
+        ldns_rbtree_free(domain_tree);
+    }
     return;
 }
 

Modified: trunk/OpenDNSSEC/signer/src/tools/zone_fetcher.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/tools/zone_fetcher.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/tools/zone_fetcher.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -412,7 +412,7 @@
                 doc = xmlTextReaderCurrentDoc(reader);
                 if (doc == NULL) {
                     se_log_error("zone fetcher could not read zone "
-                        "%s; skipping", zone_name?zone_name:"(null)");
+                        "%s; skipping", zone_name);
                     /* Don't return? try to parse the rest of the zones? */
                     ret = xmlTextReaderRead(reader);
                     continue;

Modified: trunk/OpenDNSSEC/signer/src/util/duration.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/duration.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/util/duration.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -127,8 +127,7 @@
     W = strchr(str, 'W');
     if (W) {
         if (not_weeks) {
-            se_log_error("unable to create duration from string %s",
-                P?P:"(null)");
+            se_log_error("unable to create duration from string %s", P);
             duration_cleanup(duration);
             return NULL;
         } else {

Modified: trunk/OpenDNSSEC/signer/src/util/file.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/file.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/util/file.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -345,7 +345,7 @@
         }
     } else if ((dir = se_dir_name(file)) != NULL) {
         se_log_debug("create and chown directory %s [user %ld] [group %ld]",
-           dir?dir:"(null)", (signed long) uid, (signed long) gid);
+           dir, (signed long) uid, (signed long) gid);
         if (chown(dir, uid, gid) != 0) {
             se_log_error("chown() for %s failed: %s", dir?dir:"(null)",
                 strerror(errno));

Modified: trunk/OpenDNSSEC/signer/src/util/log.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/log.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/util/log.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -180,7 +180,7 @@
     else if (strncasecmp(facility, "LOCAL7", 6) && strlen(facility) == 6)
         return LOG_LOCAL7;
     se_log_warning("syslog facility %s not supported, logging to "
-                   "log_daemon", facility?facility:"(null)");
+                   "log_daemon", facility);
     return LOG_DAEMON;
 
 }

Modified: trunk/OpenDNSSEC/signer/src/util/privdrop.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/privdrop.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/util/privdrop.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -85,6 +85,7 @@
         /* Lookup the user id in /etc/passwd */
         s = getpwnam_r(username, &pwd, buf, bufsize, &result);
         if (result == NULL) {
+            se_free((void*) buf);
             return -1;
         } else {
             uid = pwd.pw_uid;
@@ -123,6 +124,7 @@
         /* Lookup the group id in /etc/group */
         s = getgrnam_r(groupname, &grp, buf, bufsize, &result);
         if (result == NULL) {
+            se_free((void*) buf);
             return -1;
         } else {
             gid = grp.gr_gid;

Modified: trunk/OpenDNSSEC/signer/src/util/se_malloc.c
===================================================================
--- trunk/OpenDNSSEC/signer/src/util/se_malloc.c	2010-08-12 09:16:54 UTC (rev 3747)
+++ trunk/OpenDNSSEC/signer/src/util/se_malloc.c	2010-08-12 10:33:37 UTC (rev 3748)
@@ -102,7 +102,7 @@
 void
 se_rbnode_free(ldns_rbnode_t* node)
 {
-    if (node != LDNS_RBTREE_NULL) {
+    if (node && node != LDNS_RBTREE_NULL) {
         se_rbnode_free(node->left);
         se_rbnode_free(node->right);
         free((void*)node);




More information about the Opendnssec-commits mailing list