From 0acb4dc6d0339bbe87739259ba00cf57f94ae8a1 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 22 Dec 2003 14:18:48 +0100 Subject: [PATCH] Fixed a problem with crc32 in SI handling on 64bit systems --- CONTRIBUTORS | 3 +++ HISTORY | 2 ++ libsi/util.c | 10 +++++----- libsi/util.h | 21 +++++++++++---------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 82f79031..c1ae42ea 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -876,3 +876,6 @@ Emil Petersky Alessio Sangalli for providing the iso8859-1 small font + +Pedro Miguel Sequeira de Justo Teixeira + for reporting a problem with crc32 in SI handling on 64bit systems diff --git a/HISTORY b/HISTORY index 616d29f9..0ad9796d 100644 --- a/HISTORY +++ b/HISTORY @@ -2502,3 +2502,5 @@ Video Disk Recorder Revision History - Added 'cRWlock' to 'thread.[hc]'. Note that all plugin Makefiles need to define _GNU_SOURCE for this to work (see the example plugin Makefiles and 'newplugin'). +- Fixed a problem with crc32 in SI handling on 64bit systems (thanks to Pedro + Miguel Sequeira de Justo Teixeira for reportign this one). diff --git a/libsi/util.c b/libsi/util.c index 2c1c6e35..a2a6f0d2 100644 --- a/libsi/util.c +++ b/libsi/util.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.c 1.2 2003/12/13 10:42:18 kls Exp $ + * $Id: util.c 1.3 2003/12/22 14:03:03 kls Exp $ * * ***************************************************************************/ @@ -186,7 +186,7 @@ void Parsable::CheckParse() { //taken and adapted from libdtv, (c) Rolf Hakenes and VDR, (c) Klaus Schmidinger time_t DVBTime::getTime(unsigned char date_hi, unsigned char date_lo, unsigned char time_hour, unsigned char time_minute, unsigned char time_second) { - unsigned short mjd = date_hi << 8 | date_lo; + u_int16_t mjd = date_hi << 8 | date_lo; struct tm t; t.tm_sec = bcdToDec(time_second); @@ -217,7 +217,7 @@ time_t DVBTime::getDuration(unsigned char time_hour, unsigned char time_minute, //taken and adapted from libdtv, (c) Rolf Hakenes // CRC32 lookup table for polynomial 0x04c11db7 -unsigned long CRC32::crc_table[256] = { +u_int32_t CRC32::crc_table[256] = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, @@ -262,7 +262,7 @@ unsigned long CRC32::crc_table[256] = { 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4}; -unsigned long CRC32::crc32 (const char *d, int len, unsigned long crc) +u_int32_t CRC32::crc32 (const char *d, int len, u_int32_t crc) { register int i; @@ -272,7 +272,7 @@ unsigned long CRC32::crc32 (const char *d, int len, unsigned long crc) return crc; } -CRC32::CRC32(const char *d, int len, unsigned long CRCvalue) { +CRC32::CRC32(const char *d, int len, u_int32_t CRCvalue) { data=d; length=len; value=CRCvalue; diff --git a/libsi/util.h b/libsi/util.h index d6765104..db019238 100644 --- a/libsi/util.h +++ b/libsi/util.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.h 1.2 2003/12/13 10:42:20 kls Exp $ + * $Id: util.h 1.3 2003/12/22 14:07:41 kls Exp $ * * ***************************************************************************/ @@ -14,6 +14,7 @@ #define LIBSI_UTIL_H #include +#include #include #include @@ -54,8 +55,8 @@ public: template void setPointerAndOffset(const T* &p, unsigned int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); } unsigned char operator[](const unsigned int index) const { return data_->data ? data_->data[off+index] : 0; } int getLength() const { return data_->size; } - unsigned short TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } - unsigned long FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } + u_int16_t TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } + u_int32_t FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } void addOffset(unsigned int offset) { off+=offset; } private: @@ -67,9 +68,9 @@ private: virtual void assign(const unsigned char*data, unsigned int size) = 0; virtual void Delete() = 0; - unsigned short TwoBytes(const unsigned int index) const + u_int16_t TwoBytes(const unsigned int index) const { return (data[index] << 8) | data[index+1]; } - unsigned long FourBytes(const unsigned int index) const + u_int32_t FourBytes(const unsigned int index) const { return (data[index] << 24) | (data[index+1] << 16) | (data[index+2] << 8) | data[index+3]; } /*#ifdef CHARARRAY_THREADSAFE void Lock(); @@ -139,16 +140,16 @@ inline unsigned char bcdToDec(unsigned char b) { return ((b >> 4) & 0x0F) * 10 + //taken and adapted from libdtv, (c) Rolf Hakenes class CRC32 { public: - CRC32(const char *d, int len, unsigned long CRCvalue=0xFFFFFFFF); + CRC32(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF); bool isValid() { return crc32(data, length, value) == 0; } - static bool isValid(const char *d, int len, unsigned long CRCvalue=0xFFFFFFFF) { return crc32(d, len, CRCvalue) == 0; } + static bool isValid(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF) { return crc32(d, len, CRCvalue) == 0; } protected: - static unsigned long crc_table[256]; - static unsigned long crc32 (const char *d, int len, unsigned long CRCvalue); + static u_int32_t crc_table[256]; + static u_int32_t crc32 (const char *d, int len, u_int32_t CRCvalue); const char *data; int length; - unsigned long value; + u_int32_t value; }; } //end of namespace