svn commit: r184149 - projects/tcp_cc_8.x/sys/netinet

Lawrence Stewart lstewart at FreeBSD.org
Wed Oct 22 01:13:32 UTC 2008


Author: lstewart
Date: Wed Oct 22 01:13:31 2008
New Revision: 184149
URL: http://svn.freebsd.org/changeset/base/184149

Log:
  Fix a bug I just noticed in the way the TCP_CONGESTION getsockopt() code worked.
  memcpy() had the args around the wrong way and was the wrong thing to use there
  anyway.
  
  Also switch the other strncpy use in the patch over to strlcpy whilst I'm at it.

Modified:
  projects/tcp_cc_8.x/sys/netinet/cc.c
  projects/tcp_cc_8.x/sys/netinet/tcp_usrreq.c

Modified: projects/tcp_cc_8.x/sys/netinet/cc.c
==============================================================================
--- projects/tcp_cc_8.x/sys/netinet/cc.c	Wed Oct 22 00:22:32 2008	(r184148)
+++ projects/tcp_cc_8.x/sys/netinet/cc.c	Wed Oct 22 01:13:31 2008	(r184149)
@@ -164,7 +164,7 @@ cc_init()
 	cc_register_algorithm(&newreno_cc_algo);
 
 	/* set newreno to the system default */
-	strncpy(cc_algorithm, newreno_cc_algo.name, sizeof(cc_algorithm));
+	strlcpy(cc_algorithm, newreno_cc_algo.name, TCP_CA_NAME_MAX);
 }
 
 /*

Modified: projects/tcp_cc_8.x/sys/netinet/tcp_usrreq.c
==============================================================================
--- projects/tcp_cc_8.x/sys/netinet/tcp_usrreq.c	Wed Oct 22 00:22:32 2008	(r184148)
+++ projects/tcp_cc_8.x/sys/netinet/tcp_usrreq.c	Wed Oct 22 01:13:31 2008	(r184149)
@@ -1490,7 +1490,7 @@ tcp_ctloutput(struct socket *so, struct 
 			break;
 		case TCP_CONGESTION:
 			bzero(buf, sizeof(buf));
-			memcpy(&(CC_ALGO(tp)->name), buf, TCP_CA_NAME_MAX);
+			strlcpy(buf, CC_ALGO(tp)->name, TCP_CA_NAME_MAX);
 			INP_WUNLOCK(inp);
 			error = sooptcopyout(sopt, buf, TCP_CA_NAME_MAX);
 			break;


More information about the svn-src-projects mailing list