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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user