]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
coverity: add code annotation to remove false positives
authorVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 23:48:54 +0000 (00:48 +0100)
committerVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 23:49:35 +0000 (00:49 +0100)
src/client/lldpcli.c
src/daemon/event.c
src/daemon/interfaces-linux.c
src/daemon/lldpd.c

index 5498c579b5e23833657cb839963bc7b755493b14..a5952dc69514141713b831b173e0f3729c5d013e 100644 (file)
@@ -467,6 +467,8 @@ main(int argc, char *argv[])
 
        /* Process file inputs */
        while (gotinputs && !TAILQ_EMPTY(&inputs)) {
+               /* TAILQ_REMOVE does the right thing */
+               /* coverity[use_after_free] */
                struct input *first = TAILQ_FIRST(&inputs);
                log_debug("lldpctl", "process: %s", first->name);
                FILE *file = fopen(first->name, "r");
@@ -548,6 +550,8 @@ main(int argc, char *argv[])
 
 end:
        while (!TAILQ_EMPTY(&inputs)) {
+               /* TAILQ_REMOVE does the right thing */
+               /* coverity[use_after_free] */
                struct input *first = TAILQ_FIRST(&inputs);
                TAILQ_REMOVE(&inputs, first, next);
                free(first->name);
index fd7cf832ec20dc0c97c5ca8b0574cc64b9ddadc1..c05a3b3e01cee4e51da4fe9f573e083c899de0aa 100644 (file)
@@ -373,6 +373,8 @@ levent_ctl_accept(evutil_socket_t fd, short what, void *arg)
            client);
        bufferevent_enable(client->bev, EV_READ | EV_WRITE);
        log_debug("event", "new client accepted");
+       /* s has been saved by bufferevent_socket_new */
+       /* coverity[leaked_handle] */
        return;
 accept_failed:
        levent_ctl_free_client(client);
index 22e9c75291494bc058de3134f07a763ad7715245..0064c82311ec762f836b7efdf20f2dba98ffab1f 100644 (file)
@@ -807,6 +807,8 @@ interfaces_update(struct lldpd *cfg)
                }
                if (levent_iface_subscribe(cfg, s) == -1)
                        close(s);
+               /* s has been saved by levent_iface_subscribe */
+               /* coverity[leaked_handle] */
        }
 
 end:
index 849cdfc773fe8eccdc982d1c3458d33771e2b5d1..9cff3bfb8bdbb93849eeae26dec9751e270bb90d 100644 (file)
@@ -301,6 +301,8 @@ lldpd_reset_timer(struct lldpd *cfg)
                size_t output_len;
                char save[offsetof(struct lldpd_port, p_id_subtype)];
                memcpy(save, port, sizeof(save));
+               /* We intentionally partially memset port */
+               /* coverity[suspicious_sizeof] */
                memset(port, 0, sizeof(save));
                output_len = lldpd_port_serialize(port, (void**)&output);
                memcpy(port, save, sizeof(save));
@@ -577,6 +579,8 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
           freed with lldpd_port_cleanup() and therefore, the refcount
           of the chassis that was attached to it is decreased.
        */
+       /* TAILQ_REMOVE does the right thing */
+       /* coverity[use_after_free] */
        i = 0; TAILQ_FOREACH(aport, &hardware->h_rports, p_entries)
                i++;
        log_debug("decode", "%d neighbors for %s", i,