[asterisk-commits] Simplify and fix conditional in FD SET. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 9 16:07:28 CST 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: Simplify and fix conditional in FD_SET.
......................................................................


Simplify and fix conditional in FD_SET.

FD_SET contains a conditional statement to protect against buffer
overruns.  The statement was overly complicated and prevented use
of the last array element of ast_fdset.  We now just verify the fd
is less than ast_FDMAX.

Change-Id: I41895c0b497b052aef5bf49d75c817c48b326f40
---
M include/asterisk/select.h
1 file changed, 1 insertion(+), 3 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/include/asterisk/select.h b/include/asterisk/select.h
index d6d34fb..d6f9d32 100644
--- a/include/asterisk/select.h
+++ b/include/asterisk/select.h
@@ -58,9 +58,7 @@
 #define FD_SET(fd, fds) \
 	do { \
 		TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) fds; \
-		/* 32bit: FD / 32 + ((FD + 1) % 32 ? 1 : 0) < 1024 */ \
-		/* 64bit: FD / 64 + ((FD + 1) % 64 ? 1 : 0) < 512 */ \
-		if (fd / _bitsize(*bytes) + ((fd + 1) % _bitsize(*bytes) ? 1 : 0) < sizeof(*(fds)) / SIZEOF_FD_SET_FDS_BITS) { \
+		if (fd < ast_FDMAX) { \
 			bytes[fd / _bitsize(*bytes)] |= ((TYPEOF_FD_SET_FDS_BITS) 1) << (fd % _bitsize(*bytes)); \
 		} else { \
 			fprintf(stderr, "FD %d exceeds the maximum size of ast_fdset!\n", fd); \

-- 
To view, visit https://gerrit.asterisk.org/2221
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I41895c0b497b052aef5bf49d75c817c48b326f40
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list