Author: ngie
Date: Sat Dec 31 12:18:17 2016
New Revision: 310957
URL: https://svnweb.freebsd.org/changeset/base/310957

Log:
  Use strlcpy when copying `com` to pdu->community to avoid potential
  buffer overruns
  
  MFC after:    1 week
  Reported by:  Coverity
  CID:          1006823, 1006824

Modified:
  head/contrib/bsnmp/snmpd/trap.c

Modified: head/contrib/bsnmp/snmpd/trap.c
==============================================================================
--- head/contrib/bsnmp/snmpd/trap.c     Sat Dec 31 12:16:21 2016        
(r310956)
+++ head/contrib/bsnmp/snmpd/trap.c     Sat Dec 31 12:18:17 2016        
(r310957)
@@ -422,7 +422,7 @@ snmp_create_v1_trap(struct snmp_pdu *pdu
     const struct asn_oid *trap_oid)
 {
        memset(pdu, 0, sizeof(*pdu));
-       strcpy(pdu->community, com);
+       strlcpy(pdu->community, com, sizeof(pdu->community));
 
        pdu->version = SNMP_V1;
        pdu->type = SNMP_PDU_TRAP;
@@ -439,7 +439,7 @@ snmp_create_v2_trap(struct snmp_pdu *pdu
     const struct asn_oid *trap_oid)
 {
        memset(pdu, 0, sizeof(*pdu));
-       strcpy(pdu->community, com);
+       strlcpy(pdu->community, com, sizeof(pdu->community));
 
        pdu->version = SNMP_V2c;
        pdu->type = SNMP_PDU_TRAP2;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to