diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 09e3229a..0a787e50 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1051,6 +1051,8 @@ Marco Schl finally lead to finding out that the basic problem causing buffer overflows was in EnableGet()/EnablePut() being called too often for avoiding unnecessary section filter start/stops + for pointing out that if one PID can't be added, the whole cDevice::AttachReceiver() + should fail and all PIDs added so far should be deleted Jürgen Schmitz for reporting a bug in displaying the current channel when switching via the SVDRP diff --git a/HISTORY b/HISTORY index 547a8d37..68d17671 100644 --- a/HISTORY +++ b/HISTORY @@ -3026,3 +3026,6 @@ Video Disk Recorder Revision History - Now skipping code table info in SI data (suggested by Milos Kapoun). - Added missing Czech characters to fontosd-iso8859-2.c (thanks to Milos Kapoun). - Fixed a crash in the time search mechanism (reported by Reinhard Nissl). +- If one PID can't be added, the whole cDevice::AttachReceiver() will now fail + and all PIDs added so far will be deleted (thanks to Marco Schlüßler for + pointing out this one). diff --git a/device.c b/device.c index 8c6652db..b53c0ab2 100644 --- a/device.c +++ b/device.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.59 2004/10/16 13:49:35 kls Exp $ + * $Id: device.c 1.60 2004/10/17 09:39:10 kls Exp $ */ #include "device.h" @@ -248,7 +248,11 @@ bool cDevice::AddPid(int Pid, ePidType PidType) if (++pidHandles[n].used == 2 && n <= ptTeletext) { // It's a special PID that may have to be switched into "tap" mode PRINTPIDS("A"); - return SetPid(&pidHandles[n], n, true); + if (!SetPid(&pidHandles[n], n, true)) { + esyslog("ERROR: can't set PID %d on device %d", Pid, CardIndex() + 1); + DelPid(Pid, PidType); + return false; + } } PRINTPIDS("a"); return true; @@ -261,13 +265,19 @@ bool cDevice::AddPid(int Pid, ePidType PidType) // The Pid is not yet in use and we have a free slot n = a; } - else - esyslog("ERROR: no free slot for PID %d", Pid); + else { + esyslog("ERROR: no free slot for PID %d on device %d", Pid, CardIndex() + 1); + return false; + } if (n >= 0) { pidHandles[n].pid = Pid; pidHandles[n].used = 1; PRINTPIDS("C"); - return SetPid(&pidHandles[n], n, true); + if (!SetPid(&pidHandles[n], n, true)) { + esyslog("ERROR: can't set PID %d on device %d", Pid, CardIndex() + 1); + DelPid(Pid, PidType); + return false; + } } } return true; @@ -757,8 +767,13 @@ bool cDevice::AttachReceiver(cReceiver *Receiver) return true; for (int i = 0; i < MAXRECEIVERS; i++) { if (!receiver[i]) { - for (int n = 0; n < MAXRECEIVEPIDS; n++) - AddPid(Receiver->pids[n]);//XXX+ retval! + for (int n = 0; n < MAXRECEIVEPIDS; n++) { + if (!AddPid(Receiver->pids[n])) { + for ( ; n-- > 0; ) + DelPid(Receiver->pids[n]); + return false; + } + } Receiver->Activate(true); Lock(); Receiver->device = this;