From 0faae7c3f04abc13049b1a526a3d05a36e28d014 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 2 Jan 2010 10:39:50 +0100 Subject: [PATCH] Fixed handling the "CA PMT" generation (cont'd) --- ci.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ci.c b/ci.c index 02834713..6c7b0310 100644 --- a/ci.c +++ b/ci.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: ci.c 2.5 2010/01/01 13:38:02 kls Exp $ + * $Id: ci.c 2.6 2010/01/02 10:39:50 kls Exp $ */ #include "ci.h" @@ -638,13 +638,15 @@ void cCiCaPmt::AddPid(int Pid, uint8_t StreamType) void cCiCaPmt::AddCaDescriptors(int Length, const uint8_t *Data) { if (esInfoLengthPos) { - if (length + Length <= int(sizeof(capmt))) { - capmt[length++] = cmdId; - memcpy(capmt + length, Data, Length); - length += Length; - int l = length - esInfoLengthPos - 2; - capmt[esInfoLengthPos] = (l >> 8) & 0xFF; - capmt[esInfoLengthPos + 1] = l & 0xFF; + if (length + Length < int(sizeof(capmt))) { + if (Length || cmdId == CPCI_QUERY) { + capmt[length++] = cmdId; + memcpy(capmt + length, Data, Length); + length += Length; + int l = length - esInfoLengthPos - 2; + capmt[esInfoLengthPos] = (l >> 8) & 0xFF; + capmt[esInfoLengthPos + 1] = l & 0xFF; + } } else esyslog("ERROR: buffer overflow in CA descriptor");