summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/stackchk/check.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-07-06 21:11:36 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-07-06 21:11:36 +0000
commit2b596c698695c9225d02c3e704d519aceda7e924 (patch)
tree4cf1237e3747d1399987f25c24525beaa4007253 /cpukit/libmisc/stackchk/check.c
parentMove stack outside of _rtems_end marked area. (diff)
downloadrtems-2b596c698695c9225d02c3e704d519aceda7e924.tar.bz2
2007-07-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/stackchk/check.c: Make checking the integrity of the pattern area contingent on the stack checker user extension having been initialized.
Diffstat (limited to '')
-rw-r--r--cpukit/libmisc/stackchk/check.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
index bc9dc66481..3e0a39651a 100644
--- a/cpukit/libmisc/stackchk/check.c
+++ b/cpukit/libmisc/stackchk/check.c
@@ -266,10 +266,10 @@ void rtems_stack_checker_switch_extension(
pattern = (void *) Stack_check_Get_pattern_area(the_stack)->pattern;
/*
- * Check for an out of bounds stack pointer and then an overwrite
+ * Check for an out of bounds stack pointer or an overwrite
*/
-
sp_ok = Stack_check_Frame_pointer_in_range( the_stack );
+
pattern_ok = (!memcmp( pattern,
(void *) Stack_check_Pattern.pattern, PATTERN_SIZE_BYTES));
@@ -284,19 +284,26 @@ void rtems_stack_checker_switch_extension(
boolean rtems_stack_checker_is_blown( void )
{
Stack_Control *the_stack = &_Thread_Executing->Start.Initial_stack;
- void *pattern;
boolean sp_ok;
boolean pattern_ok = TRUE;
- pattern = (void *) Stack_check_Get_pattern_area(the_stack)->pattern;
-
/*
- * Check for an out of bounds stack pointer and then an overwrite
+ * Check for an out of bounds stack pointer
*/
sp_ok = Stack_check_Frame_pointer_in_range( the_stack );
- pattern_ok = (!memcmp( pattern,
- (void *) Stack_check_Pattern.pattern, PATTERN_SIZE_BYTES));
+
+ /*
+ * The stack checker must be initialized before the pattern is there
+ * to check.
+ */
+ if ( Stack_check_Initialized ) {
+ pattern_ok = (!memcmp(
+ (void *) Stack_check_Get_pattern_area(the_stack)->pattern,
+ (void *) Stack_check_Pattern.pattern,
+ PATTERN_SIZE_BYTES
+ ));
+ }
if ( !sp_ok || !pattern_ok ) {
return TRUE;