From 6c198ee80de22566925cb195a048a7c34e4954e6 Mon Sep 17 00:00:00 2001 From: leslie Date: Thu, 9 Oct 2008 20:52:22 +0800 Subject: [PATCH] viaccess: revert TPS changes, prevent date overflow on tps.bin load --- systems/viaccess/tps.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/systems/viaccess/tps.c b/systems/viaccess/tps.c index 210cfd1..d55a2f5 100644 --- a/systems/viaccess/tps.c +++ b/systems/viaccess/tps.c @@ -540,6 +540,7 @@ void cTpsKey::Set(const cTpsKey *k) void cTpsKey::Set(const unsigned char *mem) { timestamp=*((unsigned int *)mem); + if((unsigned int)timestamp>0x7FFFFFFFUL) timestamp=0x7FFFFFFFL; opmode=mem[52+3]; for(int i=0; i<3; i++) { memcpy(step[i].key,&mem[4+i*16],16); @@ -611,12 +612,7 @@ const cTpsKey *cTpsKeys::GetKey(time_t t) { ListLock(false); cTpsKey *k; - for(k=First(); k;) { - if(tTimestamp()) break; - cTpsKey *n=Next(k); - if(!n) break; // if all keys are expired, use last one - k=n; - } + for(k=First(); k; k=Next(k)) if(tTimestamp()) break; ListUnlock(); return k; } @@ -677,7 +673,7 @@ void cTpsKeys::Purge(time_t now) ListLock(true); for(cTpsKey *k=First(); k;) { cTpsKey *n=Next(k); - if(k->Timestamp()Timestamp() *nlist=new cSimpleList; for(int i=0; i