diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-07-24 17:35:34 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2004-07-24 17:35:34 +0000 |
commit | 046f0094b50768426347c29f769daeb11732d052 (patch) | |
tree | fd91555e7809eb79229c52e734b8fa63d0b78029 /cpukit/score | |
parent | 2004-07-24 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-046f0094b50768426347c29f769daeb11732d052.tar.bz2 |
2004-07-24 Joel Sherrill <joel@OARcorp.com>
PR 660/rtems
* src/threadinitialize.c, src/threadstackallocate.c: Check for
overflow when allocating stack.
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/score/src/threadinitialize.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadstackallocate.c | 20 |
3 files changed, 17 insertions, 11 deletions
diff --git a/cpukit/score/ChangeLog b/cpukit/score/ChangeLog index 23e68aaacd..735ae4e420 100644 --- a/cpukit/score/ChangeLog +++ b/cpukit/score/ChangeLog @@ -1,5 +1,11 @@ 2004-07-24 Joel Sherrill <joel@OARcorp.com> + PR 660/rtems + * src/threadinitialize.c, src/threadstackallocate.c: Check for + overflow when allocating stack. + +2004-07-24 Joel Sherrill <joel@OARcorp.com> + PR 659/rtems * src/heapsizeofuserarea.c, src/objectmp.c, src/threadinitialize.c, src/threadstackallocate.c: Check that address specified is in the diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index ebad61c92d..7f1bef7134 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -76,7 +76,7 @@ boolean _Thread_Initialize( actual_stack_size = _Thread_Stack_Allocate( the_thread, actual_stack_size ); - if ( !actual_stack_size ) + if ( !actual_stack_size || actual_stack_size < stack_size ) return FALSE; /* stack allocation failed */ stack = the_thread->Start.stack; diff --git a/cpukit/score/src/threadstackallocate.c b/cpukit/score/src/threadstackallocate.c index 05d4e91763..0da923a993 100644 --- a/cpukit/score/src/threadstackallocate.c +++ b/cpukit/score/src/threadstackallocate.c @@ -38,13 +38,14 @@ unsigned32 _Thread_Stack_Allocate( Thread_Control *the_thread, - unsigned32 stack_size + unsigned32 stack_size ) { void *stack_addr = 0; + unsigned32 the_stack_size = stack_size; - if ( !_Stack_Is_enough( stack_size ) ) - stack_size = STACK_MINIMUM_SIZE; + if ( !_Stack_Is_enough( the_stack_size ) ) + the_stack_size = STACK_MINIMUM_SIZE; /* * Call ONLY the CPU table stack allocate hook, _or_ the @@ -52,9 +53,8 @@ unsigned32 _Thread_Stack_Allocate( * routine can call the correct deallocation routine. */ - if ( _CPU_Table.stack_allocate_hook ) - { - stack_addr = (*_CPU_Table.stack_allocate_hook)( stack_size ); + if ( _CPU_Table.stack_allocate_hook ) { + stack_addr = (*_CPU_Table.stack_allocate_hook)( the_stack_size ); } else { /* @@ -68,14 +68,14 @@ unsigned32 _Thread_Stack_Allocate( * the context initialization sequence in sync. */ - stack_size = _Stack_Adjust_size( stack_size ); - stack_addr = _Workspace_Allocate( stack_size ); + the_stack_size = _Stack_Adjust_size( the_stack_size ); + stack_addr = _Workspace_Allocate( the_stack_size ); } if ( !stack_addr ) - stack_size = 0; + the_stack_size = 0; the_thread->Start.stack = stack_addr; - return stack_size; + return the_stack_size; } |