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:
parent
19a6a4a5ee
commit
fbf7977853
10
common.h
10
common.h
@ -86,6 +86,9 @@
|
|||||||
|
|
||||||
class cSatipMemoryBuffer {
|
class cSatipMemoryBuffer {
|
||||||
private:
|
private:
|
||||||
|
enum {
|
||||||
|
eMaxDataSize = MEGABYTE(2)
|
||||||
|
};
|
||||||
char *dataM;
|
char *dataM;
|
||||||
size_t sizeM;
|
size_t sizeM;
|
||||||
void *AllocBuffer(void *ptrP, size_t sizeP)
|
void *AllocBuffer(void *ptrP, size_t sizeP)
|
||||||
@ -105,7 +108,9 @@ public:
|
|||||||
size_t Add(char *dataP, size_t sizeP)
|
size_t Add(char *dataP, size_t sizeP)
|
||||||
{
|
{
|
||||||
if (sizeP > 0) {
|
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) {
|
if (dataM) {
|
||||||
memcpy(&(dataM[sizeM]), dataP, sizeP);
|
memcpy(&(dataM[sizeM]), dataP, sizeP);
|
||||||
sizeM += sizeP;
|
sizeM += sizeP;
|
||||||
@ -115,6 +120,9 @@ public:
|
|||||||
else
|
else
|
||||||
esyslog("[%s,%d]: Failed to allocate memory", __FILE__, __LINE__);
|
esyslog("[%s,%d]: Failed to allocate memory", __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
esyslog("[%s,%d]: Buffer overflow", __FILE__, __LINE__);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
char *Data(void) { return dataM; }
|
char *Data(void) { return dataM; }
|
||||||
|
Loading…
Reference in New Issue
Block a user