1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 13:37:42 +02:00

Added a memory guard for cSatipMemoryBuffer().

This commit is contained in:
Rolf Ahrenberg 2015-03-26 00:23:55 +02:00
parent 19a6a4a5ee
commit fbf7977853

View File

@ -86,6 +86,9 @@
class cSatipMemoryBuffer {
private:
enum {
eMaxDataSize = MEGABYTE(2)
};
char *dataM;
size_t sizeM;
void *AllocBuffer(void *ptrP, size_t sizeP)
@ -105,7 +108,9 @@ public:
size_t Add(char *dataP, size_t sizeP)
{
if (sizeP > 0) {
dataM = (char *)AllocBuffer(dataM, sizeM + sizeP + 1);
size_t len = sizeM + sizeP + 1;
if (len < eMaxDataSize) {
dataM = (char *)AllocBuffer(dataM, len);
if (dataM) {
memcpy(&(dataM[sizeM]), dataP, sizeP);
sizeM += sizeP;
@ -115,6 +120,9 @@ public:
else
esyslog("[%s,%d]: Failed to allocate memory", __FILE__, __LINE__);
}
else
esyslog("[%s,%d]: Buffer overflow", __FILE__, __LINE__);
}
return 0;
};
char *Data(void) { return dataM; }