Changeset d887c1b in rtems


Ignore:
Timestamp:
May 25, 2016, 12:28:34 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
dce48791
Parents:
39bcf741
git-author:
Sebastian Huber <sebastian.huber@…> (05/25/16 12:28:34)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/26/16 19:44:30)
Message:

posix: Fix sem_init() with too large initial value

Close #2721.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/seminit.c

    r39bcf741 rd887c1b  
    4444  POSIX_Semaphore_Control   *the_semaphore;
    4545
    46   if ( !sem )
     46  if ( sem == NULL ) {
    4747    rtems_set_errno_and_return_minus_one( EINVAL );
     48  }
     49
     50  if ( value > SEM_VALUE_MAX ) {
     51    rtems_set_errno_and_return_minus_one( EINVAL );
     52  }
    4853
    4954  _Objects_Allocator_lock();
  • testsuites/psxtests/psxsem01/init.c

    r39bcf741 rd887c1b  
    108108  rv = sem_destroy( &sem );
    109109  rtems_test_assert( rv == 0 );
     110}
     111
     112static void test_sem_init_too_large_inital_value(void)
     113{
     114  sem_t sem;
     115  int   rv;
     116
     117  errno = 0;
     118  rv = sem_init( &sem, 0, SEM_VALUE_MAX + 1 );
     119  rtems_test_assert( rv == -1 );
     120  rtems_test_assert( errno == EINVAL );
    110121}
    111122
     
    380391  test_sem_wait_during_delete();
    381392  test_sem_post_overflow();
     393  test_sem_init_too_large_inital_value();
    382394
    383395  /* Try adding in unlinking before closing... (can we still open?) */
Note: See TracChangeset for help on using the changeset viewer.