summaryrefslogtreecommitdiff
path: root/libsi/descriptor.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2004-06-06 18:00:00 +0200
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2004-06-06 18:00:00 +0200
commitc281d01c089f4c9410a2756d3bcd99a56f702c86 (patch)
tree8fdb640ba345e60cb3de7816ef4983fb78e829a2 /libsi/descriptor.c
parentb81bf2d1c92e2ac820d2116c66f328869eb627cd (diff)
downloadvdr-patch-lnbsharing-c281d01c089f4c9410a2756d3bcd99a56f702c86.tar.gz
vdr-patch-lnbsharing-c281d01c089f4c9410a2756d3bcd99a56f702c86.tar.bz2
Version 1.3.10vdr-1.3.10
- Fixed some default parameters in 'skincurses'. - Fixed cBitmap::DrawPixel(), which messed with other bitmaps' palettes in case the pixel coordinates were outside this bitmap (thanks to Sascha Volkenandt for reporting this one). - The cBitmap::DrawText() function now doesn't set any background pixels if the given background color is clrTransparent. This allows drawing "transparent" texts (suggested by Sascha Volkenandt). - The cBitmap::SetXpm() function now ignores unused "none" color entries, which some broken graphics tools write into XPM files (suggested by Sascha Volkenandt). - No longer setting lnb voltage if the frontend is not DVB-S (thanks to Marco Schlüßler). - Fixed displaying the current channel when switching via the SVDRP command CHAN (thanks to Jürgen Schmitz for reporting this one). - Fixed missing audio after replaying a DVD (thanks to Marco Schlüßler). - Added a note about the default assignment of the color keys to MANUAL. - Added a note about NPTL ("Native Posix Thread Library") to the INSTALL file (apparently the "fix" in version 1.3.0 didn't really fix this). - Modified 'libsi' to require callers to state the buffer sizes when getting strings in order to avoid buffer overflows (thanks to Philip Lawatsch for debugging a buffer overflow in eit.c).
Diffstat (limited to 'libsi/descriptor.c')
-rw-r--r--libsi/descriptor.c134
1 files changed, 72 insertions, 62 deletions
diff --git a/libsi/descriptor.c b/libsi/descriptor.c
index 685722e..eb921c9 100644
--- a/libsi/descriptor.c
+++ b/libsi/descriptor.c
@@ -6,7 +6,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * $Id: descriptor.c 1.12 2004/03/26 15:25:28 kls Exp $
+ * $Id: descriptor.c 1.13 2004/06/06 14:47:30 kls Exp $
* *
***************************************************************************/
@@ -84,53 +84,61 @@ int ExtendedEventDescriptors::getMaximumTextLength(const char *separation1, cons
}
char *ExtendedEventDescriptors::getText(const char *separation1, const char *separation2) {
- char *text=new char[getMaximumTextLength(separation1, separation2)];
- return getText(text, separation1, separation2);
+ int size = getMaximumTextLength(separation1, separation2);
+ char *text=new char[size];
+ return getText(text, size, separation1, separation2);
}
-char *ExtendedEventDescriptors::getText(char *buffer, const char *separation1, const char *separation2) {
+char *ExtendedEventDescriptors::getText(char *buffer, int size, const char *separation1, const char *separation2) {
int index=0, len;
- char tempbuf[256];
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
continue;
- d->text.getText(tempbuf);
- len=strlen(tempbuf);
- if (len) {
- memcpy(buffer+index, tempbuf, len);
- index+=len;
- }
+ d->text.getText(buffer+index, size);
+ len = strlen(buffer+index);
+ index += len;
+ size -= len;
}
+ int sepLen1 = strlen(separation1);
+ int sepLen2 = strlen(separation2);
+ bool separated = false;
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
continue;
- strcpy(buffer+index, separation2); // let's have a separator between the long text and the items
- index += strlen(separation2);
ExtendedEventDescriptor::Item item;
for (Loop::Iterator it; d->itemLoop.hasNext(it); ) {
item=d->itemLoop.getNext(it);
- item.itemDescription.getText(tempbuf);
- len=strlen(tempbuf);
- if (len) {
- memcpy(buffer+index, tempbuf, len);
- index+=len;
+ if (!separated && size > sepLen2) {
+ strcpy(buffer+index, separation2); // let's have a separator between the long text and the items
+ index += sepLen2;
+ size -= sepLen2;
+ separated = true;
+ }
+
+ item.itemDescription.getText(buffer+index, size);
+ len = strlen(buffer+index);
+ index += len;
+ size -= len;
+ if (size > sepLen1) {
+ strcpy(buffer+index, separation1);
+ index += sepLen1;
+ size -= sepLen1;
}
- strcpy(buffer+index, separation1);
- index += strlen(separation1);
-
- item.item.getText(tempbuf);
- len=strlen(tempbuf);
- if (len) {
- memcpy(buffer+index, tempbuf, len);
- index+=len;
+
+ item.item.getText(buffer+index, size);
+ len = strlen(buffer+index);
+ index += len;
+ size -= len;
+ if (size > sepLen2) {
+ strcpy(buffer+index, separation2);
+ index += sepLen2;
+ size -= sepLen2;
}
- strcpy(buffer+index, separation2);
- index += strlen(separation2);
}
}
@@ -150,23 +158,21 @@ int ExtendedEventDescriptors::getMaximumTextPlainLength() {
}
char *ExtendedEventDescriptors::getTextPlain() {
- char *text=new char[getMaximumTextPlainLength()];
- return getTextPlain(text);
+ int size = getMaximumTextPlainLength();
+ char *text=new char[size];
+ return getTextPlain(text, size);
}
-char *ExtendedEventDescriptors::getTextPlain(char *buffer) {
+char *ExtendedEventDescriptors::getTextPlain(char *buffer, int size) {
int index=0, len;
- char tempbuf[256];
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
continue;
- d->text.getText(tempbuf);
- len=strlen(tempbuf);
- if (len) {
- memcpy(buffer+index, tempbuf, len);
- index+=len;
- }
+ d->text.getText(buffer+index, size);
+ len = strlen(buffer+index);
+ index += len;
+ size -= len;
}
buffer[index]='\0';
return buffer;
@@ -174,25 +180,27 @@ char *ExtendedEventDescriptors::getTextPlain(char *buffer) {
int ExtendedEventDescriptors::getMaximumTextItemizedLength(const char *separation1, const char *separation2) {
int ret=0;
- int sepLength=strlen(separation1)+strlen(separation2)-2;
+ int sepLength=strlen(separation1)+strlen(separation2);
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
continue;
- //The length includes two 8-bit length fields which have already been subtracted from sepLength
+ //The length includes two 8-bit length fields which have already been subtracted from sepLength //XXX kls 2004-06-06: what does this mean???
ret+=d->itemLoop.getLength()+sepLength;
}
return ret;
}
char *ExtendedEventDescriptors::getTextItemized(const char *separation1, const char *separation2) {
- char *text=new char[getMaximumTextItemizedLength(separation1, separation2)];
- return getTextItemized(text, separation1, separation2);
+ int size = getMaximumTextItemizedLength(separation1, separation2);
+ char *text=new char[size];
+ return getTextItemized(text, size, separation1, separation2);
}
-char *ExtendedEventDescriptors::getTextItemized(char *buffer, const char *separation1, const char *separation2) {
+char *ExtendedEventDescriptors::getTextItemized(char *buffer, int size, const char *separation1, const char *separation2) {
int index=0, len;
- char tempbuf[256];
+ int sepLen1 = strlen(separation1);
+ int sepLen2 = strlen(separation2);
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
@@ -202,23 +210,25 @@ char *ExtendedEventDescriptors::getTextItemized(char *buffer, const char *separa
for (Loop::Iterator it; d->itemLoop.hasNext(it); ) {
item=d->itemLoop.getNext(it);
- item.itemDescription.getText(tempbuf);
- len=strlen(tempbuf);
- if (len) {
- memcpy(buffer+index, tempbuf, len);
- index+=len;
+ item.itemDescription.getText(buffer+index, size);
+ len = strlen(buffer+index);
+ index += len;
+ size -= len;
+ if (size > sepLen1) {
+ strcpy(buffer+index, separation1);
+ index += sepLen1;
+ size -= sepLen1;
}
- strcpy(buffer+index, separation1);
- index += strlen(separation1);
-
- item.item.getText(tempbuf);
- len=strlen(tempbuf);
- if (len) {
- memcpy(buffer+index, tempbuf, len);
- index+=len;
+
+ item.item.getText(buffer+index, size);
+ len = strlen(buffer+index);
+ index += len;
+ size -= len;
+ if (size > sepLen2) {
+ strcpy(buffer+index, separation2);
+ index += sepLen2;
+ size -= sepLen2;
}
- strcpy(buffer+index, separation2);
- index += strlen(separation2);
}
}
buffer[index]='\0';
@@ -227,7 +237,7 @@ char *ExtendedEventDescriptors::getTextItemized(char *buffer, const char *separa
//returns the itemized text pair by pair. Maximum length for buffers is 256.
//Return value is false if and only if the end of the list is reached.
-bool ExtendedEventDescriptors::getTextItemized(Loop::Iterator &it, bool &valid, char *itemDescription, char *itemText) {
+bool ExtendedEventDescriptors::getTextItemized(Loop::Iterator &it, bool &valid, char *itemDescription, char *itemText, int sizeItemDescription, int sizeItemText) {
//The iterator has to store two values: The descriptor index (4bit)
//and the item loop index (max overall length 256, min item length 16 => max number 128 => 7bit)
valid=false;
@@ -244,8 +254,8 @@ bool ExtendedEventDescriptors::getTextItemized(Loop::Iterator &it, bool &valid,
if (d->itemLoop.hasNext(it)) {
item=d->itemLoop.getNext(it);
- item.item.getText(itemDescription);
- item.itemDescription.getText(itemText);
+ item.item.getText(itemDescription, sizeItemDescription);
+ item.itemDescription.getText(itemText, sizeItemText);
valid=true;
break;
} else {