]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
coverity: fix a false positive in SNMP transport
authorVincent Bernat <vincent@bernat.im>
Tue, 8 Apr 2014 07:17:29 +0000 (09:17 +0200)
committerVincent Bernat <vincent@bernat.im>
Tue, 8 Apr 2014 07:17:29 +0000 (09:17 +0200)
`remote` is not expected to be a NULL-terminated string. However, just
in case it is used as one somewhere, we alloc the appropriate space for
it.

src/daemon/agent_priv.c

index ee1438250aa1ec13b108a98ea980ae5646c9ca39..10929e47223c4ff66541404eadb1fb8d8209c90b 100644 (file)
@@ -148,7 +148,7 @@ agent_priv_unix_transport(const char *string, int len, int local)
        t->flags = NETSNMP_TRANSPORT_FLAG_STREAM;
 
        if ((t->remote = (u_char *)
-               malloc(strlen(addr.sun_path))) == NULL) {
+               calloc(1, strlen(addr.sun_path) + 1)) == NULL) {
                agent_priv_unix_close(t);
                netsnmp_transport_free(t);
                return NULL;