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 MFC after: 1 month PR: 215721
This commit is contained in:
parent
b5bbd2a17c
commit
2e590d595e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311263
@ -1231,7 +1231,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 +1256,7 @@ snmp_send_packet(struct snmp_pdu * pdu)
|
||||
}
|
||||
free(buf);
|
||||
|
||||
return pdu->request_id;
|
||||
return (pdu->request_id);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1352,7 +1352,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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user