forked from Imagelibrary/rtems
2004-03-30 David Querbach <querbach@realtime.bc.ca>
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.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2004-03-30 David Querbach <querbach@realtime.bc.ca>
|
||||||
|
|
||||||
|
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 <querbach@realtime.bc.ca>
|
2004-03-30 David Querbach <querbach@realtime.bc.ca>
|
||||||
|
|
||||||
PR 596/tests
|
PR 596/tests
|
||||||
|
|||||||
@@ -21,26 +21,19 @@
|
|||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#define MESSAGE_SIZE (sizeof(long) * 4)
|
|
||||||
|
|
||||||
void Fill_buffer(
|
void Fill_buffer(
|
||||||
char *source,
|
char *source,
|
||||||
long *buffer
|
long *buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int i;
|
int i, j;
|
||||||
/*
|
|
||||||
memcpy( buffer, source, 16 );
|
|
||||||
*/
|
|
||||||
p = source;
|
p = source;
|
||||||
for ( i=0 ; i<MESSAGE_SIZE ; i++ ) {
|
for ( i = 0 ; i < MESSAGE_SIZE / sizeof(long) ; i++ ) {
|
||||||
buffer[i] = *p++;
|
buffer[i] = 0;
|
||||||
buffer[i] <<= 8;
|
for ( j = sizeof(long) - 1; j >= 0; j-- ) {
|
||||||
buffer[i] |= *p++;
|
buffer[i] |= *p++ << (8 * j);
|
||||||
buffer[i] <<= 8;
|
}
|
||||||
buffer[i] |= *p++;
|
|
||||||
buffer[i] <<= 8;
|
|
||||||
buffer[i] |= *p++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
#define TEST_INIT
|
#define TEST_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#define MESSAGE_SIZE (sizeof(long) * 4)
|
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,21 +20,18 @@
|
|||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#define MESSAGE_SIZE (4)
|
|
||||||
|
|
||||||
void Put_buffer(
|
void Put_buffer(
|
||||||
long *buffer
|
long *buffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
/*
|
char c;
|
||||||
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) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_id Queue_id[ 4 ]; /* array of queue ids */
|
||||||
TEST_EXTERN rtems_name Queue_name[ 4 ]; /* array of queue names */
|
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 */
|
/* end of include file */
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
char big_send_buffer[2048];
|
char big_send_buffer[2048];
|
||||||
char big_receive_buffer[2048];
|
char big_receive_buffer[2048];
|
||||||
|
|
||||||
long buffer[ 4 ];
|
long buffer[ MESSAGE_SIZE / sizeof(long) ];
|
||||||
|
|
||||||
#define MESSAGE_SIZE (sizeof(long) * 4)
|
|
||||||
|
|
||||||
void dope_buffer(unsigned char *buff,
|
void dope_buffer(unsigned char *buff,
|
||||||
int buff_size,
|
int buff_size,
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#define MESSAGE_SIZE (sizeof(long) * 4)
|
|
||||||
|
|
||||||
rtems_task Task_2(
|
rtems_task Task_2(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user