Made CharArray::DataOwnData::assign() in 'libsi' more robust against invalid data and changed CharArray::DataOwnData::Delete() so that it sets 'size' and 'data' to 0

This commit is contained in:
Klaus Schmidinger 2006-02-18 11:21:00 +01:00
parent b8cdca858b
commit 273d6c53a6
3 changed files with 10 additions and 1 deletions

View File

@ -606,6 +606,8 @@ Oliver Endriss <o.endriss@gmx.de>
for making cEIT::cEIT() drop EPG events that have a zero start time or duration for making cEIT::cEIT() drop EPG events that have a zero start time or duration
for reporting an unnecessary OSD draw operation caused by the audio track description for reporting an unnecessary OSD draw operation caused by the audio track description
display in the ST:TNG skin's channel display display in the ST:TNG skin's channel display
for suggesting to make CharArray::DataOwnData::assign() in 'libsi' more robust
against invalid data
Reinhard Walter Buchner <rw.buchner@freenet.de> Reinhard Walter Buchner <rw.buchner@freenet.de>
for adding some satellites to 'sources.conf' for adding some satellites to 'sources.conf'

View File

@ -4336,3 +4336,6 @@ Video Disk Recorder Revision History
overflows can be better detected (thanks to Marcel Wiesweg). overflows can be better detected (thanks to Marcel Wiesweg).
- Checking data size in CaDescriptor::Parse() and LinkageDescriptor::Parse() of - Checking data size in CaDescriptor::Parse() and LinkageDescriptor::Parse() of
'libsi' to avoid crashes with invalid data (thanks to Marcel Wiesweg). 'libsi' to avoid crashes with invalid data (thanks to Marcel Wiesweg).
- Made CharArray::DataOwnData::assign() in 'libsi' more robust against invalid
data (suggested by Oliver Endriss). Also changed CharArray::DataOwnData::Delete()
so that it sets 'size' and 'data' to 0.

View File

@ -6,7 +6,7 @@
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* $Id: util.c 1.6 2006/02/18 10:38:20 kls Exp $ * $Id: util.c 1.7 2006/02/18 11:17:50 kls Exp $
* * * *
***************************************************************************/ ***************************************************************************/
@ -119,6 +119,8 @@ CharArray::DataOwnData::~DataOwnData() {
void CharArray::DataOwnData::assign(const unsigned char*d, int s) { void CharArray::DataOwnData::assign(const unsigned char*d, int s) {
Delete(); Delete();
if (!d || s > 100000 || s <= 0) // ultimate plausibility check
return;
size=s; size=s;
unsigned char *newdata=new unsigned char[size]; unsigned char *newdata=new unsigned char[size];
memcpy(newdata, d, size); memcpy(newdata, d, size);
@ -127,6 +129,8 @@ void CharArray::DataOwnData::assign(const unsigned char*d, int s) {
void CharArray::DataOwnData::Delete() { void CharArray::DataOwnData::Delete() {
delete[] data; delete[] data;
size=0;
data=0;
} }
CharArray::DataForeignData::~DataForeignData() { CharArray::DataForeignData::~DataForeignData() {