svn commit: r321011 - head/lib/libthr/thread

Pedro F. Giffuni pfg at FreeBSD.org
Sat Jul 15 15:00:14 UTC 2017


Author: pfg
Date: Sat Jul 15 15:00:13 2017
New Revision: 321011
URL: https://svnweb.freebsd.org/changeset/base/321011

Log:
  libthr: check for possible overflow in the pthread_barrier_init() count.
  
  Following up on r320900, where the check for negative count values was
  removed, add a check to prevent integer overflow. This is to account that
  b_count, b_waiters but most importantly the total number of threads in
  the system are signed values.
  
  Discussed with:	kib
  MFC after:	2 weeks

Modified:
  head/lib/libthr/thread/thr_barrier.c

Modified: head/lib/libthr/thread/thr_barrier.c
==============================================================================
--- head/lib/libthr/thread/thr_barrier.c	Sat Jul 15 14:57:24 2017	(r321010)
+++ head/lib/libthr/thread/thr_barrier.c	Sat Jul 15 15:00:13 2017	(r321011)
@@ -100,7 +100,7 @@ _pthread_barrier_init(pthread_barrier_t *barrier,
 	pthread_barrier_t bar;
 	int pshared;
 
-	if (barrier == NULL || count == 0)
+	if (barrier == NULL || count == 0 || count > INT_MAX)
 		return (EINVAL);
 
 	if (attr == NULL || *attr == NULL ||


More information about the svn-src-all mailing list