From a841314365099df23b3cd1ea7e6c01f8174dda17 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 30 Mar 2004 19:46:38 +0000 Subject: 2004-03-30 David Querbach PR 595/tests * sp13/fillbuff.c, sp13/init.c, sp13/putbuff.c, sp13/system.h, sp13/task1.c, sp13/task2.c: Fill_buffer() in fillbuff.c overruns the supplied buffer due to confusion in the definition of MESSAGE_SIZE. Some files in the sp13 test treat MESSAGE_SIZE as a count of bytes, others treat it as a count of longs. --- testsuites/sptests/ChangeLog | 9 +++++++++ testsuites/sptests/sp13/fillbuff.c | 21 +++++++-------------- testsuites/sptests/sp13/init.c | 2 -- testsuites/sptests/sp13/putbuff.c | 21 +++++++++------------ testsuites/sptests/sp13/system.h | 4 ++++ testsuites/sptests/sp13/task1.c | 4 +--- testsuites/sptests/sp13/task2.c | 2 -- 7 files changed, 30 insertions(+), 33 deletions(-) (limited to 'testsuites') diff --git a/testsuites/sptests/ChangeLog b/testsuites/sptests/ChangeLog index 265031cf5d..cac5728838 100644 --- a/testsuites/sptests/ChangeLog +++ b/testsuites/sptests/ChangeLog @@ -1,3 +1,12 @@ +2004-03-30 David Querbach + + PR 595/tests + * sp13/fillbuff.c, sp13/init.c, sp13/putbuff.c, sp13/system.h, + sp13/task1.c, sp13/task2.c: Fill_buffer() in fillbuff.c overruns the + supplied buffer due to confusion in the definition of MESSAGE_SIZE. + Some files in the sp13 test treat MESSAGE_SIZE as a count of bytes, + others treat it as a count of longs. + 2004-03-30 David Querbach PR 596/tests diff --git a/testsuites/sptests/sp13/fillbuff.c b/testsuites/sptests/sp13/fillbuff.c index 6182f5d314..003e5206ed 100644 --- a/testsuites/sptests/sp13/fillbuff.c +++ b/testsuites/sptests/sp13/fillbuff.c @@ -21,26 +21,19 @@ #include "system.h" -#define MESSAGE_SIZE (sizeof(long) * 4) - void Fill_buffer( char *source, long *buffer ) { char *p; - int i; -/* - memcpy( buffer, source, 16 ); -*/ + int i, j; + p = source; - for ( i=0 ; i= 0; j-- ) { + buffer[i] |= *p++ << (8 * j); + } } } diff --git a/testsuites/sptests/sp13/init.c b/testsuites/sptests/sp13/init.c index 228c60594f..19da141702 100644 --- a/testsuites/sptests/sp13/init.c +++ b/testsuites/sptests/sp13/init.c @@ -24,8 +24,6 @@ #define TEST_INIT #include "system.h" -#define MESSAGE_SIZE (sizeof(long) * 4) - rtems_task Init( rtems_task_argument argument ) diff --git a/testsuites/sptests/sp13/putbuff.c b/testsuites/sptests/sp13/putbuff.c index 19c443f07c..004ce76dc0 100644 --- a/testsuites/sptests/sp13/putbuff.c +++ b/testsuites/sptests/sp13/putbuff.c @@ -20,21 +20,18 @@ #include "system.h" -#define MESSAGE_SIZE (4) - void Put_buffer( long *buffer ) { - int i; -/* - printf( "%16s", (char *)buffer ); -*/ - for ( i=0 ; i< MESSAGE_SIZE ; i++ ) { - printf( "%c%c%c%c", (char) (buffer[i] >> 24), - (char) (buffer[i] >> 16 & 0xff), - (char) (buffer[i] >> 8 & 0xff), - (char) (buffer[i] >> 0 & 0xff) ); - } + int i, j; + char c; + for ( i = 0; i < MESSAGE_SIZE / sizeof(long); i++ ) { + for ( j = sizeof(long) - 1; j >= 0; j-- ) { + if ( (c = (buffer[i] >> (8 * j)) & 0xFF) == 0 ) + return; + printf( "%c", c ); + } + } } diff --git a/testsuites/sptests/sp13/system.h b/testsuites/sptests/sp13/system.h index 77bb81f943..33c5d6f16f 100644 --- a/testsuites/sptests/sp13/system.h +++ b/testsuites/sptests/sp13/system.h @@ -66,4 +66,8 @@ TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */ TEST_EXTERN rtems_id Queue_id[ 4 ]; /* array of queue ids */ TEST_EXTERN rtems_name Queue_name[ 4 ]; /* array of queue names */ +/* test configuration */ + +#define MESSAGE_SIZE (sizeof(long) * 4) /* must be multiple of sizeof(long) */ + /* end of include file */ diff --git a/testsuites/sptests/sp13/task1.c b/testsuites/sptests/sp13/task1.c index e10452377a..d48abf4209 100644 --- a/testsuites/sptests/sp13/task1.c +++ b/testsuites/sptests/sp13/task1.c @@ -23,9 +23,7 @@ char big_send_buffer[2048]; char big_receive_buffer[2048]; -long buffer[ 4 ]; - -#define MESSAGE_SIZE (sizeof(long) * 4) +long buffer[ MESSAGE_SIZE / sizeof(long) ]; void dope_buffer(unsigned char *buff, int buff_size, diff --git a/testsuites/sptests/sp13/task2.c b/testsuites/sptests/sp13/task2.c index 8aa9df479b..79d705a2eb 100644 --- a/testsuites/sptests/sp13/task2.c +++ b/testsuites/sptests/sp13/task2.c @@ -20,8 +20,6 @@ #include "system.h" -#define MESSAGE_SIZE (sizeof(long) * 4) - rtems_task Task_2( rtems_task_argument argument ) -- cgit v1.2.3