summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-02-04 15:45:39 +0000
committerngie <ngie@FreeBSD.org>2017-02-04 15:45:39 +0000
commit2b1b84b411c899c171f9d3fbdbd16f76b1007ddf (patch)
tree5468d5e441805c167474d6656119ee363ff89247
parentdc202296d1079d0218c9188ad77a0e037cf12518 (diff)
downloadFreeBSD-src-2b1b84b411c899c171f9d3fbdbd16f76b1007ddf.zip
FreeBSD-src-2b1b84b411c899c171f9d3fbdbd16f76b1007ddf.tar.gz
MFC r311263:
Use calloc instead of malloc with buffers in snmp_{recv,send}_packet This doesn't fix the issue noted in the PR, but at the very least it cleans up the error so it looks a bit more sane, and in the event that bsnmp did wander off into the weeds, the likelihood of it crashing with more sensible output is greater, in my opinion MFC counter set high so I have enough time to resolve the real underlying bug in bsnmpwalk PR: 215721
-rw-r--r--contrib/bsnmp/lib/snmpclient.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c
index dba93c9..2dc9eb8 100644
--- a/contrib/bsnmp/lib/snmpclient.c
+++ b/contrib/bsnmp/lib/snmpclient.c
@@ -1234,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);
}
@@ -1259,7 +1259,7 @@ snmp_send_packet(struct snmp_pdu * pdu)
}
free(buf);
- return pdu->request_id;
+ return (pdu->request_id);
}
/*
@@ -1355,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);
}
OpenPOWER on IntegriCloud