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