Changeset 04b4b38 in rtems


Ignore:
Timestamp:
03/30/04 19:46:24 (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Children:
81cc5b2
Parents:
6a15087
Message:

2004-03-30 David Querbach <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.
Location:
c/src/tests/sptests
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/sptests/ChangeLog

    r6a15087 r04b4b38  
     12004-03-30      David Querbach <querbach@realtime.bc.ca>
     2
     3        PR 595/tests
     4        * sp13/fillbuff.c, sp13/init.c, sp13/putbuff.c, sp13/system.h,
     5        sp13/task1.c, sp13/task2.c: Fill_buffer() in fillbuff.c overruns the
     6        supplied buffer due to confusion in the definition of MESSAGE_SIZE.
     7        Some files in the sp13 test treat MESSAGE_SIZE as a count of bytes,
     8        others treat it as a count of longs.
     9
    1102004-03-30      David Querbach <querbach@realtime.bc.ca>
    211
  • c/src/tests/sptests/sp13/fillbuff.c

    r6a15087 r04b4b38  
    2222#include "system.h"
    2323
    24 #define MESSAGE_SIZE (sizeof(long) * 4)
    25 
    2624void Fill_buffer(
    2725  char *source,
     
    3028{
    3129  char *p;
    32   int i;
    33 /*
    34   memcpy( buffer, source, 16 );
    35 */
     30  int i, j;
     31
    3632  p = source;
    37   for ( i=0 ; i<MESSAGE_SIZE ; i++ ) {
    38     buffer[i] = *p++;
    39     buffer[i] <<= 8;
    40     buffer[i] |= *p++;
    41     buffer[i] <<= 8;
    42     buffer[i] |= *p++;
    43     buffer[i] <<= 8;
    44     buffer[i] |= *p++;
     33  for ( i = 0 ; i < MESSAGE_SIZE / sizeof(long) ; i++ ) {
     34    buffer[i] = 0;
     35    for ( j = sizeof(long) - 1; j >= 0; j-- ) {
     36      buffer[i] |= *p++ << (8 * j);
     37    }
    4538  }
    4639}
  • c/src/tests/sptests/sp13/init.c

    r6a15087 r04b4b38  
    2424#define TEST_INIT
    2525#include "system.h"
    26 
    27 #define MESSAGE_SIZE (sizeof(long) * 4)
    2826
    2927rtems_task Init(
  • c/src/tests/sptests/sp13/putbuff.c

    r6a15087 r04b4b38  
    2121#include "system.h"
    2222
    23 #define MESSAGE_SIZE (4)
    24 
    2523void Put_buffer(
    2624  long *buffer
    2725)
    2826{
    29   int i;
    30 /*
    31   printf( "%16s", (char *)buffer );
    32 */
    33   for ( i=0 ; i< MESSAGE_SIZE ; i++ ) {
    34     printf( "%c%c%c%c", (char) (buffer[i] >> 24),
    35                         (char) (buffer[i] >> 16 & 0xff),
    36                         (char) (buffer[i] >> 8 & 0xff),
    37                         (char) (buffer[i] >> 0 & 0xff) );
     27  int i, j;
     28  char c;
     29
     30  for ( i = 0; i < MESSAGE_SIZE / sizeof(long); i++ ) {
     31    for ( j = sizeof(long) - 1; j >= 0; j-- ) {
     32      if ( (c = (buffer[i] >> (8 * j)) & 0xFF) == 0 )
     33        return;
     34      printf( "%c", c );
     35    }
    3836  }
    39 
    4037}
  • c/src/tests/sptests/sp13/system.h

    r6a15087 r04b4b38  
    6767TEST_EXTERN rtems_name Queue_name[ 4 ];      /* array of queue names */
    6868
     69/* test configuration */
     70
     71#define MESSAGE_SIZE (sizeof(long) * 4)  /* must be multiple of sizeof(long) */
     72
    6973/* end of include file */
  • c/src/tests/sptests/sp13/task1.c

    r6a15087 r04b4b38  
    2424char    big_receive_buffer[2048];
    2525
    26 long    buffer[ 4 ];
    27 
    28 #define MESSAGE_SIZE (sizeof(long) * 4)
     26long    buffer[ MESSAGE_SIZE / sizeof(long) ];
    2927
    3028void dope_buffer(unsigned char *buff,
  • c/src/tests/sptests/sp13/task2.c

    r6a15087 r04b4b38  
    2020
    2121#include "system.h"
    22 
    23 #define MESSAGE_SIZE (sizeof(long) * 4)
    2422
    2523rtems_task Task_2(
Note: See TracChangeset for help on using the changeset viewer.