summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2016-12-23 14:08:14 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2016-12-23 14:08:14 +0100
commit68acf8815c369e1bedfc0fa8f066975001803454 (patch)
tree5329367f8dbf0d5680936845b7e4f95b5673b5bc /tools.h
parent736f2fed426b3b3ca68a5ce808586ab16e5bb070 (diff)
downloadvdr-68acf8815c369e1bedfc0fa8f066975001803454.tar.gz
vdr-68acf8815c369e1bedfc0fa8f066975001803454.tar.bz2
Fixed a possible buffer overflow in handling CA descriptors
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h22
1 files changed, 21 insertions, 1 deletions
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: