svn commit: r312059 - stable/11/contrib/bsnmp/snmpd

Ngie Cooper ngie at FreeBSD.org
Fri Jan 13 09:19:10 UTC 2017


Author: ngie
Date: Fri Jan 13 09:19:09 2017
New Revision: 312059
URL: https://svnweb.freebsd.org/changeset/base/312059

Log:
  MFC r311381:
  
  lsock_init_port: address issues with initializing sockaddr_un object
  
  - Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*].
  - Use SUN_LEN(..) instead of spelling out calculation longhand (inspired
    by comment by jmallett).
  
  Tested with:	dgram and stream support with both bsnmpwalk and snmpwalk
  
  CID:		1006825

Modified:
  stable/11/contrib/bsnmp/snmpd/trans_lsock.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmpd/trans_lsock.c
==============================================================================
--- stable/11/contrib/bsnmp/snmpd/trans_lsock.c	Fri Jan 13 09:19:04 2017	(r312058)
+++ stable/11/contrib/bsnmp/snmpd/trans_lsock.c	Fri Jan 13 09:19:09 2017	(r312059)
@@ -305,10 +305,9 @@ lsock_init_port(struct tport *tp)
 			return (SNMP_ERR_RES_UNAVAIL);
 		}
 
-		strcpy(sa.sun_path, p->name);
+		strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path));
 		sa.sun_family = AF_LOCAL;
-		sa.sun_len = strlen(p->name) +
-		    offsetof(struct sockaddr_un, sun_path);
+		sa.sun_len = SUN_LEN(&sa);
 
 		(void)remove(p->name);
 
@@ -360,10 +359,9 @@ lsock_init_port(struct tport *tp)
 			return (SNMP_ERR_GENERR);
 		}
 
-		strcpy(sa.sun_path, p->name);
+		strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path));
 		sa.sun_family = AF_LOCAL;
-		sa.sun_len = strlen(p->name) +
-		    offsetof(struct sockaddr_un, sun_path);
+		sa.sun_len = SUN_LEN(&sa);
 
 		(void)remove(p->name);
 


More information about the svn-src-all mailing list