summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-11-23 08:21:51 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-11-23 08:21:51 +0100
commitc35685d34d5c87c03d2be100989a829268d6d946 (patch)
treedad84fe3e653b5d94b497359cedd72921eb8ae67
parentacb5ebc5a8a9cdf6ee0bdd47d544be7238a3e0f6 (diff)
downloadDLT-daemon-c35685d34d5c87c03d2be100989a829268d6d946.tar.gz
Fixed buffer overflow problem in buffer library.
-rwxr-xr-xinclude/dlt/dlt_common.h9
-rwxr-xr-xinclude/dlt/dlt_version.h4
-rwxr-xr-xsrc/shared/dlt_common.c5
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
@@ -551,15 +551,6 @@ typedef struct
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 */
int size; /* size of data area in shared memory */
unsigned char* mem; /* pointer to data area in 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;