summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/stackchk
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-01-18 23:04:09 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-01-18 23:04:09 +0000
commit2bac94892099e9d7570bc3cf3c91a8e66ee4e1af (patch)
tree08fb81acb6f255467a6c7a5b118dd52826aeeba1 /cpukit/libmisc/stackchk
parent2010-01-18 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-2bac94892099e9d7570bc3cf3c91a8e66ee4e1af.tar.bz2
2010-01-18 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 12 Coverity Id 13 Coverity Id 14 Coverity Id 15 * libmisc/stackchk/check.c: Rewrote loop to avoid possible buffer overruns when the pattern area size is not a multiple of 16. There were no current ports impacted by this but better to be safe.
Diffstat (limited to 'cpukit/libmisc/stackchk')
-rw-r--r--cpukit/libmisc/stackchk/check.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
index 702707dc07..02bb631f40 100644
--- a/cpukit/libmisc/stackchk/check.c
+++ b/cpukit/libmisc/stackchk/check.c
@@ -6,7 +6,7 @@
* CPU grows up or down and installs the correct
* extension routines for that direction.
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -135,7 +135,12 @@ Stack_Control Stack_check_Interrupt_stack;
*/
void Stack_check_Initialize( void )
{
+ int i;
uint32_t *p;
+ static pattern[ 4 ] = {
+ 0xFEEDF00D, 0x0BAD0D06, /* FEED FOOD to BAD DOG */
+ 0xDEADF00D, 0x600D0D06 /* DEAD FOOD but GOOD DOG */
+ };
if (Stack_check_Initialized)
return;
@@ -143,15 +148,9 @@ void Stack_check_Initialize( void )
/*
* Dope the pattern and fill areas
*/
-
- for ( p = Stack_check_Pattern.pattern;
- p < &Stack_check_Pattern.pattern[PATTERN_SIZE_WORDS];
- p += 4
- ) {
- p[0] = 0xFEEDF00D; /* FEED FOOD to BAD DOG */
- p[1] = 0x0BAD0D06;
- p[2] = 0xDEADF00D; /* DEAD FOOD GOOD DOG */
- p[3] = 0x600D0D06;
+ p = Stack_check_Pattern.pattern;
+ for ( i = 0; i < PATTERN_SIZE_WORDS; i++ ) {
+ p[i] = pattern[ i%4 ];
}
/*