]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix#520: Errors found by static analysis from Tomas Hozza(redhat).
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Aug 2013 13:31:09 +0000 (13:31 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Aug 2013 13:31:09 +0000 (13:31 +0000)
git-svn-id: file:///svn/unbound/trunk@2942 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
libunbound/libworker.c
testcode/streamtcp.c
util/tube.c
validator/autotrust.c

index 92f25db2a6948659c78b63b6c240d51d777bf121..9ddbe5b21bb3d7cdee12beb84076d711d2b91de4 100644 (file)
@@ -1,3 +1,6 @@
+21 Aug 2013: Wouter
+       - Fix#520: Errors found by static analysis from Tomas Hozza(redhat).
+
 20 Aug 2013: Wouter
        - Fix for 2038, with time_t instead of uint32_t.
 
index dd3316d002511cf2fe448c75d43821b28abd8f31..8f2aa489caf7a63e08e0e4c361d3e015dcb219bb 100644 (file)
@@ -198,7 +198,10 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
        }
        numports = cfg_condense_ports(cfg, &ports);
        if(numports == 0) {
+               int locked = !w->is_bg || w->is_bg_thread;
                libworker_delete(w);
+               if(locked)
+                       lock_basic_unlock(&ctx->cfglock);
                return NULL;
        }
        w->back = outside_network_create(w->base, cfg->msg_buffer_size,
index dbdf1408c1d529fc1513f7d6bfd90abe387d7252..06a18e4cfafb01d2469ca19bc3144bc4ef4a025b 100644 (file)
@@ -121,9 +121,9 @@ write_q(int fd, int udp, SSL* ssl, ldns_buffer* buf, uint16_t id,
                exit(1);
        }
        qinfo.qname = memdup(ldns_rdf_data(rdf), ldns_rdf_size(rdf));
+       if(!qinfo.qname) fatal_exit("out of memory");
        (void)dname_count_size_labels(qinfo.qname, &qinfo.qname_len);
        ldns_rdf_deep_free(rdf);
-       if(!qinfo.qname) fatal_exit("out of memory");
 
        /* qtype and qclass */
        qinfo.qtype = ldns_get_rr_type_by_name(strtype);
index 28c51d79d16d22e05b881e13a42a6ccad72ba291..fde84967fda6f4ddd11273fe2ae5c33d2b534f2a 100644 (file)
@@ -368,7 +368,7 @@ int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len,
                return 0;
        }
        d = 0;
-       while(d != (ssize_t)*len) {
+       while(d < (ssize_t)*len) {
                if((r=read(fd, (*buf)+d, (size_t)((ssize_t)*len)-d)) == -1) {
                        log_err("tube msg read failed: %s", strerror(errno));
                        (void)fd_set_nonblock(fd);
index 1e24b4c7b17b95f85a349c34d9e82b4e79816a12..dc7cbf639e9942b73116fcf25807a052efca12ac 100644 (file)
@@ -976,9 +976,13 @@ void autr_write_file(struct module_env* env, struct trust_anchor* tp)
        char* fname = tp->autr->file;
        char tempf[2048];
        log_assert(tp->autr);
+       if(!env) {
+               log_err("autr_write_file: Module environment is NULL.");
+               return;
+       }
        /* unique name with pid number and thread number */
        snprintf(tempf, sizeof(tempf), "%s.%d-%d", fname, (int)getpid(),
-               env&&env->worker?*(int*)env->worker:0);
+               env->worker?*(int*)env->worker:0);
        verbose(VERB_ALGO, "autotrust: write to disk: %s", tempf);
        out = fopen(tempf, "w");
        if(!out) {