From 68acf8815c369e1bedfc0fa8f066975001803454 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 23 Dec 2016 14:08:14 +0100 Subject: Fixed a possible buffer overflow in handling CA descriptors --- tools.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tools.h') diff --git a/tools.h b/tools.h index f2ba3157..73cca5a3 100644 --- a/tools.h +++ b/tools.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 4.4 2016/12/13 12:13:46 kls Exp $ + * $Id: tools.h 4.5 2016/12/23 13:56:35 kls Exp $ */ #ifndef __TOOLS_H @@ -775,6 +775,26 @@ public: bool Load(const char *Directory, bool DirsOnly = false); }; +class cDynamicBuffer { +private: + uchar *buffer; + int initialSize; + int size; // the total size of the buffer (bytes in memory) + int used; // the number of used bytes, starting at the beginning of the buffer + bool Realloc(int NewSize); + bool Assert(int NewSize) { return size < NewSize ? Realloc(NewSize) : true; } // inline for performance! +public: + cDynamicBuffer(int InitialSize = 1024); + ~cDynamicBuffer(); + void Append(const uchar *Data, int Length); + void Append(uchar Data) { if (Assert(used + 1)) buffer[used++] = Data; } + void Set(int Index, uchar Data) { if (Assert(Index + 1)) buffer[Index] = Data; } + uchar Get(int Index) { return Index < used ? buffer[Index] : 0; } + void Clear(void) { used = 0; } + uchar *Data(void) { return buffer; } + int Length(void) { return used; } + }; + class cHashObject : public cListObject { friend class cHashBase; private: -- cgit v1.2.3