diff options
author | Renato Botelho <renato@netgate.com> | 2017-02-09 11:26:48 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-02-09 11:26:48 -0200 |
commit | 4a05f5440acda223e6a0ec5157bc32ecc0f09ff9 (patch) | |
tree | 4c2ece480e5d4155ed35bec62996de40eb179f18 /contrib/bsnmp/lib | |
parent | 681a482d8fc4bfc14a24f7a9d75cca6337f2a520 (diff) | |
parent | a1e52233c91fd46e666297270ab655f1abff8535 (diff) | |
download | FreeBSD-src-4a05f5440acda223e6a0ec5157bc32ecc0f09ff9.zip FreeBSD-src-4a05f5440acda223e6a0ec5157bc32ecc0f09ff9.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'contrib/bsnmp/lib')
-rw-r--r-- | contrib/bsnmp/lib/snmp.c | 6 | ||||
-rw-r--r-- | contrib/bsnmp/lib/snmpclient.c | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/contrib/bsnmp/lib/snmp.c b/contrib/bsnmp/lib/snmp.c index 68f46f9..d86f88a 100644 --- a/contrib/bsnmp/lib/snmp.c +++ b/contrib/bsnmp/lib/snmp.c @@ -1154,8 +1154,11 @@ snmp_pdu_dump(const struct snmp_pdu *pdu) void snmp_value_free(struct snmp_value *value) { - if (value->syntax == SNMP_SYNTAX_OCTETSTRING) + + if (value->syntax == SNMP_SYNTAX_OCTETSTRING) { free(value->v.octetstring.octets); + value->v.octetstring.octets = NULL; + } value->syntax = SNMP_SYNTAX_NULL; } @@ -1216,6 +1219,7 @@ snmp_pdu_free(struct snmp_pdu *pdu) for (i = 0; i < pdu->nbindings; i++) snmp_value_free(&pdu->bindings[i]); + pdu->nbindings = 0; } /* diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c index 90b7d4a..10c58f5 100644 --- a/contrib/bsnmp/lib/snmpclient.c +++ b/contrib/bsnmp/lib/snmpclient.c @@ -728,8 +728,11 @@ snmp_table_fetch_async(const struct snmp_table *descr, void *list, work->last_change = 0; table_init_pdu(descr, &work->pdu); - if (snmp_pdu_send(&work->pdu, table_cb, work) == -1) + if (snmp_pdu_send(&work->pdu, table_cb, work) == -1) { + free(work); + work = NULL; return (-1); + } return (0); } @@ -1231,7 +1234,7 @@ snmp_send_packet(struct snmp_pdu * pdu) struct asn_buf b; ssize_t ret; - if ((buf = malloc(snmp_client.txbuflen)) == NULL) { + if ((buf = calloc(1, snmp_client.txbuflen)) == NULL) { seterr(&snmp_client, "%s", strerror(errno)); return (-1); } @@ -1256,7 +1259,7 @@ snmp_send_packet(struct snmp_pdu * pdu) } free(buf); - return pdu->request_id; + return (pdu->request_id); } /* @@ -1352,7 +1355,7 @@ snmp_receive_packet(struct snmp_pdu *pdu, struct timeval *tv) socklen_t optlen; #endif - if ((buf = malloc(snmp_client.rxbuflen)) == NULL) { + if ((buf = calloc(1, snmp_client.rxbuflen)) == NULL) { seterr(&snmp_client, "%s", strerror(errno)); return (-1); } |