From c35685d34d5c87c03d2be100989a829268d6d946 Mon Sep 17 00:00:00 2001 From: Alexander Wenzel Date: Wed, 23 Nov 2011 08:21:51 +0100 Subject: Fixed buffer overflow problem in buffer library. --- include/dlt/dlt_common.h | 9 --------- include/dlt/dlt_version.h | 4 ++-- src/shared/dlt_common.c | 5 ++++- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index f6a46d5..2a320fe 100755 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -549,15 +549,6 @@ typedef struct int32_t buffersize; /**< size of receiver buffer */ } DltReceiver; -typedef struct -{ - char* buffer; /**< Ptr. to buffer */ - uint32_t size; /**< Maximum size of buffer */ - uint32_t pos_write; /**< current writing position in bytes*/ - uint32_t pos_read; /**< current reading position in bytes*/ - uint32_t count; /**< nr. of entries */ -} DltRingBuffer; - typedef struct { unsigned char* shm; /* pointer to beginning of shared memory */ diff --git a/include/dlt/dlt_version.h b/include/dlt/dlt_version.h index 6bb5cce..ca2bfc3 100755 --- a/include/dlt/dlt_version.h +++ b/include/dlt/dlt_version.h @@ -3,10 +3,10 @@ #define __VERSION_H_ #define PACKAGE_VERSION_STATE "" -#define PACKAGE_VERSION "2.4.1" +#define PACKAGE_VERSION "2.4.2" #define PACKAGE_MAJOR_VERSION "2" #define PACKAGE_MINOR_VERSION "4" -#define PACKAGE_PATCH_LEVEL "1" +#define PACKAGE_PATCH_LEVEL "2" #define PACKAGE_REVISION "" #endif diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 8e2b6d4..1ebc696 100755 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -2547,7 +2547,7 @@ int dlt_buffer_push(DltBuffer *buf,const unsigned char *data,unsigned int size) int dlt_buffer_push3(DltBuffer *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3) { int free_size; - int write, read; + int write, read, count; DltBufferBlockHead head; if(!buf->mem) { @@ -2559,6 +2559,7 @@ int dlt_buffer_push3(DltBuffer *buf,const unsigned char *data1,unsigned int size // get current write pointer write = ((int*)(buf->shm))[0]; read = ((int*)(buf->shm))[1]; + count = ((int*)(buf->shm))[2]; // check pointers if((read>buf->size) || (write>buf->size)) @@ -2571,6 +2572,8 @@ int dlt_buffer_push3(DltBuffer *buf,const unsigned char *data1,unsigned int size // calculate free size if(read>write) free_size = read - write; + else if(count && (write == read)) + free_size = 0; else free_size = buf->size - write + read; -- cgit v1.2.1