From: leslie Date: Mon, 14 Sep 2009 12:30:12 +0000 (+0800) Subject: enforce constness of data in EMM processing chain X-Git-Tag: upstream/620~167 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=d8538c97ba47d41b4bba9da79ed75ff3cfb6396f;p=sasc-ng.git enforce constness of data in EMM processing chain --- diff --git a/cam.c b/cam.c index f822cef..4222736 100644 --- a/cam.c +++ b/cam.c @@ -288,7 +288,7 @@ public: cSimpleList systems; // cLogChain(int CardNum, bool soft, int src, int tr); - void Process(int pid, unsigned char *data); + void Process(int pid, const unsigned char *data); bool Parse(const unsigned char *cat); }; @@ -298,7 +298,7 @@ cLogChain::cLogChain(int CardNum, bool soft, int src, int tr) active=delayed=false; } -void cLogChain::Process(int pid, unsigned char *data) +void cLogChain::Process(int pid, const unsigned char *data) { if(active) { for(cSystem *sys=systems.First(); sys; sys=systems.Next(sys)) diff --git a/system-common.c b/system-common.c index e7bea94..749d1aa 100644 --- a/system-common.c +++ b/system-common.c @@ -173,7 +173,7 @@ bool cSystemScCore::ProcessECM(const cEcmInfo *ecm, unsigned char *source) return res; } -void cSystemScCore::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemScCore::ProcessEMM(int pid, int caid, const unsigned char *buffer) { cSmartCard *card=smartcards.LockCard(scId); if(card) { diff --git a/system-common.h b/system-common.h index efe2a89..f31c974 100644 --- a/system-common.h +++ b/system-common.h @@ -106,7 +106,7 @@ private: public: cSystemScCore(const char *Name, int Pri, int ScId, const char *ScName); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *data); + virtual void ProcessEMM(int pid, int caid, const unsigned char *data); }; #endif //___SYSTEM_COMMON_H diff --git a/system.h b/system.h index 56c920e..6a405d1 100644 --- a/system.h +++ b/system.h @@ -116,7 +116,7 @@ public: virtual int CheckECM(const cEcmInfo *ecm, const unsigned char *data, bool sync); virtual void CheckECMResult(const cEcmInfo *ecm, const unsigned char *data, bool result); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *buffer)=0; - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer) {}; + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer) {}; virtual void ParseCADescriptor(cSimpleList *ecms, unsigned short sysId, int source, const unsigned char *data, int len); virtual void ParseCAT(cPids *pids, const unsigned char *buffer, int source, int transponder); unsigned char *CW(void) { return cw; } diff --git a/systems/cardclient/cc.c b/systems/cardclient/cc.c index f38ed71..3532e08 100644 --- a/systems/cardclient/cc.c +++ b/systems/cardclient/cc.c @@ -193,7 +193,7 @@ private: public: cSystemCardClient(void); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer); + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer); }; cSystemCardClient::cSystemCardClient(void) @@ -237,7 +237,7 @@ bool cSystemCardClient::ProcessECM(const cEcmInfo *ecm, unsigned char *data) return false; } -void cSystemCardClient::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemCardClient::ProcessEMM(int pid, int caid, const unsigned char *buffer) { cCardClient *cc=0; while((cc=staticCcl.FindBySysId(caid,cc))) diff --git a/systems/irdeto/irdeto1.c b/systems/irdeto/irdeto1.c index ceaf718..81b89aa 100644 --- a/systems/irdeto/irdeto1.c +++ b/systems/irdeto/irdeto1.c @@ -221,7 +221,7 @@ private: public: cSystemIrd(void); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *source); - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer); + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer); }; cSystemIrd::cSystemIrd(void) @@ -277,17 +277,14 @@ bool cSystemIrd::ProcessECM(const cEcmInfo *ecm, unsigned char *source) return false; } -void cSystemIrd::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemIrd::ProcessEMM(int pid, int caid, const unsigned char *data) { int i, numKeys=0, date=0; unsigned char adr[10], id[4], *pk[4], prov, *mk=0, prvId[3]={0,0,0}; - int n=SCT_LEN(buffer); - unsigned char savebuf[4096]; - if(n>(int)sizeof(savebuf)) { - PRINTF(L_SYS_EMM,"%d: paket size %d to big for savebuffer in IrdetoLog",CardNum(),n); - return; - } + int n=SCT_LEN(data); + unsigned char *buffer=AUTOMEM(n); + memcpy(buffer,data,n); int index=cParseIrdeto::AddrLen(buffer); memset(adr,0,sizeof(adr)); @@ -387,7 +384,6 @@ void cSystemIrd::ProcessEMM(int pid, int caid, unsigned char *buffer) // lastKey: save cpu time if we get bursts of the same key if((numKeys>0 && (id[0]!=lastKey || numKeys>1)) || mk) { - memcpy(savebuf,buffer,n); // save the buffer cIrdCardInfo *ci=Icards.First(); unsigned char *chkkey=AUTOMEM(max(sizeof(ci->PMK),sizeof(ci->HMK))); while(ci) { @@ -436,7 +432,7 @@ void cSystemIrd::ProcessEMM(int pid, int caid, unsigned char *buffer) } LBEND(); - memcpy(buffer,savebuf,n); // restore the buffer + memcpy(buffer,data,n); // restore the buffer } ci=Icards.Next(ci); } diff --git a/systems/irdeto/irdeto2.c b/systems/irdeto/irdeto2.c index 56b6df6..4251b72 100644 --- a/systems/irdeto/irdeto2.c +++ b/systems/irdeto/irdeto2.c @@ -123,7 +123,7 @@ private: public: cSystemIrd2(void); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *data); + virtual void ProcessEMM(int pid, int caid, const unsigned char *data); }; cSystemIrd2::cSystemIrd2(void) @@ -204,7 +204,7 @@ bool cSystemIrd2::ProcessECM(const cEcmInfo *ecm, unsigned char *data) return false; } -void cSystemIrd2::ProcessEMM(int pid, int caid, unsigned char *data) +void cSystemIrd2::ProcessEMM(int pid, int caid, const unsigned char *data) { int prov=0; //XXX how to get provider here?? diff --git a/systems/nagra/nagra1.c b/systems/nagra/nagra1.c index 9413199..0ef7771 100644 --- a/systems/nagra/nagra1.c +++ b/systems/nagra/nagra1.c @@ -691,7 +691,7 @@ public: cSystemNagra(void); virtual ~cSystemNagra(); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer); + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer); }; cSystemNagra::cSystemNagra(void) @@ -863,7 +863,7 @@ bool cSystemNagra::ProcessECM(const cEcmInfo *ecm, unsigned char *data) return true; } -void cSystemNagra::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemNagra::ProcessEMM(int pid, int caid, const unsigned char *buffer) { const int id=buffer[10]*256+buffer[11]; static const unsigned char tester[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x4B }; diff --git a/systems/nagra/nagra2.c b/systems/nagra/nagra2.c index 056490e..20b4eef 100644 --- a/systems/nagra/nagra2.c +++ b/systems/nagra/nagra2.c @@ -1264,7 +1264,7 @@ public: cSystemNagra2(void); ~cSystemNagra2(); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer); + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer); }; cSystemNagra2::cSystemNagra2(void) @@ -1400,7 +1400,7 @@ bool cSystemNagra2::ProcessECM(const cEcmInfo *ecm, unsigned char *data) return true; } -void cSystemNagra2::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemNagra2::ProcessEMM(int pid, int caid, const unsigned char *buffer) { int cmdLen=buffer[9]-5; int id=buffer[10]*256+buffer[11]; diff --git a/systems/seca/seca.c b/systems/seca/seca.c index 78d11fc..0a84b8e 100644 --- a/systems/seca/seca.c +++ b/systems/seca/seca.c @@ -1177,7 +1177,7 @@ public: cSystemSeca(void); virtual ~cSystemSeca(); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer); + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer); }; cSystemSeca::cSystemSeca(void) @@ -1561,7 +1561,7 @@ void cSystemSeca::Permute(unsigned char *data, const unsigned char *pdata, const for(int i=7; i>=0; i--) data[i] = P[i] ? pdata[P[i]] : 0; } -void cSystemSeca::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemSeca::ProcessEMM(int pid, int caid, const unsigned char *buffer) { if(buffer[0]!=0x84) return; // we only support shared updates diff --git a/systems/shl/shl.c b/systems/shl/shl.c index af42e4b..d5e7fa3 100644 --- a/systems/shl/shl.c +++ b/systems/shl/shl.c @@ -421,7 +421,7 @@ public: cSystemShl(void); virtual ~cSystemShl(); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *source); - virtual void ProcessEMM(int pid, int caid, unsigned char *buffer); + virtual void ProcessEMM(int pid, int caid, const unsigned char *buffer); }; cSystemShl::cSystemShl(void) @@ -602,7 +602,7 @@ void cSystemShl::ProcessCw(const unsigned char *data, int prvId, const unsigned } } -void cSystemShl::ProcessEMM(int pid, int caid, unsigned char *buffer) +void cSystemShl::ProcessEMM(int pid, int caid, const unsigned char *buffer) { int n=SCT_LEN(buffer)-3; buffer+=3; diff --git a/systems/viaccess/viaccess.c b/systems/viaccess/viaccess.c index dcb9952..01f5b54 100644 --- a/systems/viaccess/viaccess.c +++ b/systems/viaccess/viaccess.c @@ -356,7 +356,7 @@ private: public: cSystemViaccess(void); virtual bool ProcessECM(const cEcmInfo *ecm, unsigned char *data); - virtual void ProcessEMM(int pid, int caid, unsigned char *data); + virtual void ProcessEMM(int pid, int caid, const unsigned char *data); virtual void ParseCADescriptor(cSimpleList *ecms, unsigned short sysId, int source, const unsigned char *data, int len); }; @@ -410,7 +410,7 @@ bool cSystemViaccess::ProcessECM(const cEcmInfo *ecm, unsigned char *data) return false; } -void cSystemViaccess::ProcessEMM(int pid, int caid, unsigned char *data) +void cSystemViaccess::ProcessEMM(int pid, int caid, const unsigned char *data) { for(cViaccessCardInfo *mkey=Vcards.First(); mkey; mkey=Vcards.Next(mkey)) { int updtype;