svn commit: r275967 - head/sys/netinet

Michael Tuexen tuexen at FreeBSD.org
Sat Dec 20 21:17:29 UTC 2014


Author: tuexen
Date: Sat Dec 20 21:17:28 2014
New Revision: 275967
URL: https://svnweb.freebsd.org/changeset/base/275967

Log:
  Fix and harmonize the validation of PR-SCTP policies.
  
  Reported by:	Coverity
  CID:		1232044
  MFC after:	3 days

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c	Sat Dec 20 20:07:48 2014	(r275966)
+++ head/sys/netinet/sctp_usrreq.c	Sat Dec 20 21:17:28 2014	(r275967)
@@ -3639,10 +3639,10 @@ flags_out:
 			policy = sprstat->sprstat_policy;
 #if defined(SCTP_DETAILED_STR_STATS)
 			if ((stcb != NULL) &&
-			    (policy != SCTP_PR_SCTP_NONE) &&
 			    (sid < stcb->asoc.streamoutcnt) &&
-			    ((policy == SCTP_PR_SCTP_ALL) ||
-			    (PR_SCTP_VALID_POLICY(policy)))) {
+			    (policy != SCTP_PR_SCTP_NONE) &&
+			    ((policy <= SCTP_PR_SCTP_MAX) ||
+			    (policy == SCTP_PR_SCTP_ALL))) {
 				if (policy == SCTP_PR_SCTP_ALL) {
 					sprstat->sprstat_abandoned_unsent = stcb->asoc.strmout[sid].abandoned_unsent[0];
 					sprstat->sprstat_abandoned_sent = stcb->asoc.strmout[sid].abandoned_sent[0];
@@ -3652,8 +3652,8 @@ flags_out:
 				}
 #else
 			if ((stcb != NULL) &&
-			    (policy == SCTP_PR_SCTP_ALL) &&
-			    (sid < stcb->asoc.streamoutcnt)) {
+			    (sid < stcb->asoc.streamoutcnt) &&
+			    (policy == SCTP_PR_SCTP_ALL)) {
 				sprstat->sprstat_abandoned_unsent = stcb->asoc.strmout[sid].abandoned_unsent[0];
 				sprstat->sprstat_abandoned_sent = stcb->asoc.strmout[sid].abandoned_sent[0];
 #endif
@@ -3676,8 +3676,8 @@ flags_out:
 			policy = sprstat->sprstat_policy;
 			if ((stcb != NULL) &&
 			    (policy != SCTP_PR_SCTP_NONE) &&
-			    ((policy == SCTP_PR_SCTP_ALL) ||
-			    (PR_SCTP_VALID_POLICY(policy)))) {
+			    ((policy <= SCTP_PR_SCTP_MAX) ||
+			    (policy == SCTP_PR_SCTP_ALL))) {
 				if (policy == SCTP_PR_SCTP_ALL) {
 					sprstat->sprstat_abandoned_unsent = stcb->asoc.abandoned_unsent[0];
 					sprstat->sprstat_abandoned_sent = stcb->asoc.abandoned_sent[0];
@@ -6038,7 +6038,7 @@ sctp_setopt(struct socket *so, int optna
 			SCTP_CHECK_AND_CAST(info, optval, struct sctp_default_prinfo, optsize);
 			SCTP_FIND_STCB(inp, stcb, info->pr_assoc_id);
 
-			if (PR_SCTP_INVALID_POLICY(info->pr_policy)) {
+			if (info->pr_policy > SCTP_PR_SCTP_MAX) {
 				SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
 				error = EINVAL;
 				break;


More information about the svn-src-head mailing list