diff -ruN epgdumpr2-utf8.orig/Makefile epgdumpr2-utf8/Makefile --- epgdumpr2-utf8.orig/Makefile 2009-03-15 21:33:35.000000000 +0900 +++ epgdumpr2-utf8/Makefile 2010-01-13 23:40:18.000000000 +0900 @@ -1,12 +1,13 @@ +PREFIX = /usr/local TARGETS = epgdump OBJ_TARGETS = epgdump.o aribstr.o eit.o ts.o util.o sdt.o HEDDERDEPEND = eit.h sdt.h aribstr.h ts.h util.h LANG=C CC = gcc -CFLAGS = -std=c99 -O2 -Wall -g +CFLAGS = -std=c99 -O2 -Wall -g -Werror -Wno-return-type #LDFLAGS = -pthread -LIBS = +LIBS = .c.o: ${CC} ${CFLAGS} -c $< @@ -21,3 +22,6 @@ clean: rm -f core ${TARGETS} *.o + +install: + install -m 755 ${TARGETS} ${PREFIX}/bin diff -ruN epgdumpr2-utf8.orig/aribstr.c epgdumpr2-utf8/aribstr.c --- epgdumpr2-utf8.orig/aribstr.c 2009-11-18 12:35:20.000000000 +0900 +++ epgdumpr2-utf8/aribstr.c 2010-01-31 18:13:53.000000000 +0900 @@ -39,7 +39,7 @@ static int *m_pLockingGL; static int *m_pLockingGR; static int *m_pSingleGL; - + static BYTE m_byEscSeqCount; static BYTE m_byEscSeqIndex; static bool m_bIsEscSeqDrcs; @@ -318,7 +318,7 @@ fptr = code; tptr = xcode; - iconv(cd, &fptr, &inbyte, &tptr, &outbyte); + iconv(cd, (char **)&fptr, &inbyte, &tptr, &outbyte); iconv_close(cd); @@ -622,23 +622,25 @@ void LockingShiftGL(const BYTE byIndexG) { // LSx - m_pLockingGL = &m_CodeG[byIndexG]; + m_pLockingGL = &m_CodeG[(int)byIndexG]; } void LockingShiftGR(const BYTE byIndexG) { // LSxR - m_pLockingGR = &m_CodeG[byIndexG]; + m_pLockingGR = &m_CodeG[(int)byIndexG]; } void SingleShiftGL(const BYTE byIndexG) { // SSx - m_pSingleGL = &m_CodeG[byIndexG]; + m_pSingleGL = &m_CodeG[(int)byIndexG]; } -const bool DesignationGSET(const BYTE byIndexG, const BYTE byCode) +const bool DesignationGSET(const BYTE byIndexG_arg, const BYTE byCode) { + int byIndexG = (int)byIndexG_arg; + // Gのグラフィックセットを割り当てる switch(byCode){ case 0x42U : m_CodeG[byIndexG] = CODE_KANJI; return true; // Kanji @@ -660,8 +662,10 @@ } } -const bool DesignationDRCS(const BYTE byIndexG, const BYTE byCode) +const bool DesignationDRCS(const BYTE byIndexG_arg, const BYTE byCode) { + int byIndexG = (int)byIndexG_arg; + // DRCSのグラフィックセットを割り当てる switch(byCode){ case 0x40U : m_CodeG[byIndexG] = CODE_UNKNOWN; return true; // DRCS-0 diff -ruN epgdumpr2-utf8.orig/eit.h epgdumpr2-utf8/eit.h --- epgdumpr2-utf8.orig/eit.h 2009-11-18 12:23:01.000000000 +0900 +++ epgdumpr2-utf8/eit.h 2010-01-13 23:42:58.000000000 +0900 @@ -28,7 +28,7 @@ typedef struct _EITbody { int event_id; char start_time[5]; - char duration[3]; + unsigned char duration[3]; int running_status; int free_CA_mode; int descriptors_loop_length; diff -ruN epgdumpr2-utf8.orig/epgdump.c epgdumpr2-utf8/epgdump.c --- epgdumpr2-utf8.orig/epgdump.c 2009-11-18 12:23:01.000000000 +0900 +++ epgdumpr2-utf8/epgdump.c 2010-01-13 23:22:29.000000000 +0900 @@ -145,6 +145,9 @@ char Category[1024]; char ServiceName[1024]; +/* prototype */ +extern int strrep(char *buf, char *mae, char *ato); + void xmlspecialchars(char *str) { strrep(str, "&", "&"); diff -ruN epgdumpr2-utf8.orig/ts.c epgdumpr2-utf8/ts.c --- epgdumpr2-utf8.orig/ts.c 2009-11-18 12:23:01.000000000 +0900 +++ epgdumpr2-utf8/ts.c 2010-01-13 22:38:44.000000000 +0900 @@ -12,7 +12,7 @@ static int ridx = -1; TSpacket pk; - + unsigned char buf[1024]; int boff; @@ -37,7 +37,7 @@ } retry: - + /* 戻すべき残りがあるか? */ if(ridx >= 0 && secs[ridx].cont) { /* バッファチェック */ @@ -65,16 +65,16 @@ } } */ - + boff = 12; secs[ridx].seclen = getBit(&secs[ridx].cur.payload[secs[ridx].curlen], &boff, 12) + 3; // ヘッダ - + /* if(secs[ridx].seclen == 2334) { printf("aa"); } */ - + /* TSデータ長-設定済みデータ長 */ if(secs[ridx].seclen > len) { memcpy(secs[ridx].buf, &secs[ridx].cur.payload[secs[ridx].curlen], len); @@ -83,7 +83,7 @@ secs[ridx].cont = 1; /* 次のレコード読み込み */ } else { - memcpy(secs[ridx].buf, + memcpy(secs[ridx].buf, &secs[ridx].cur.payload[secs[ridx].curlen], secs[ridx].seclen); secs[ridx].setlen = secs[ridx].seclen; secs[ridx].curlen += secs[ridx].seclen; @@ -143,9 +143,9 @@ } */ - + pk.rcount = rcount; - + boff = 0; pk.sync = getBit(buf, &boff, 8); pk.transport_error_indicator = getBit(buf, &boff, 1); @@ -192,7 +192,7 @@ continue ; } - /* + /* if the Transport Stream packet carries the first byte of a PSI section, the payload_unit_start_indicator value shall be '1', indicating that the first byte of the payload of this Transport Stream packet carries the pointer_field. */ @@ -202,8 +202,11 @@ pk.payloadlen -= 1; } memset(pk.payload, 0xFF, sizeof(pk.payload)); + if(pk.payloadlen > sizeof(pk.payload)) + continue; memcpy(pk.payload, payptr, pk.payloadlen); - + + /* if(pk.rcount == 62) { printf("62\n"); @@ -213,7 +216,7 @@ printf("63\n"); } */ - + /* 興味のあるpidか確認 */ for(int i = 0;i < size; i++) { if(secs[i].pid == pk.pid) { @@ -234,7 +237,7 @@ secs[i].setlen = secs[i].cur.payloadlen; secs[i].cont = 1; continue; - } + } memcpy(secs[i].buf, secs[i].cur.payload, secs[i].seclen); secs[i].setlen = secs[i].seclen; secs[i].curlen = secs[i].seclen; @@ -250,7 +253,7 @@ len = secs[i].seclen - secs[i].setlen; if(len > secs[i].cur.payloadlen) { /* 全体転送 */ - memcpy(&secs[i].buf[secs[i].setlen], + memcpy(&secs[i].buf[secs[i].setlen], secs[i].cur.payload, secs[i].cur.payloadlen); secs[i].setlen += secs[i].cur.payloadlen; continue; @@ -295,7 +298,7 @@ 0x119B4BE9UL, 0x155A565EUL, 0x18197087UL, 0x1CD86D30UL, 0x029F3D35UL, 0x065E2082UL, 0x0B1D065BUL, 0x0FDC1BECUL, 0x3793A651UL, 0x3352BBE6UL, 0x3E119D3FUL, 0x3AD08088UL, 0x2497D08DUL, 0x2056CD3AUL, 0x2D15EBE3UL, 0x29D4F654UL, 0xC5A92679UL, 0xC1683BCEUL, 0xCC2B1D17UL, 0xC8EA00A0UL, 0xD6AD50A5UL, 0xD26C4D12UL, 0xDF2F6BCBUL, 0xDBEE767CUL, 0xE3A1CBC1UL, 0xE760D676UL, 0xEA23F0AFUL, 0xEEE2ED18UL, 0xF0A5BD1DUL, 0xF464A0AAUL, 0xF9278673UL, 0xFDE69BC4UL, 0x89B8FD09UL, 0x8D79E0BEUL, 0x803AC667UL, 0x84FBDBD0UL, 0x9ABC8BD5UL, 0x9E7D9662UL, 0x933EB0BBUL, 0x97FFAD0CUL, 0xAFB010B1UL, 0xAB710D06UL, 0xA6322BDFUL, 0xA2F33668UL, 0xBCB4666DUL, 0xB8757BDAUL, 0xB5365D03UL, 0xB1F740B4UL - }; + }; for (n = 0; n < len; n++) { c = (c << 8) ^ CrcTable[((((c >> 24) & 0xFF) ^ buf[n]) & 0XFF)]; @@ -307,6 +310,11 @@ int checkcrc(SECcache *secs) { + /* regard a section with more than MAXSECLEN data as an error. */ + if(secs->seclen > MAXSECLEN) { + return 0; + } + /* セクションの終りに置かれる4バイトのCRC32は、 CRC計算の結果0になるように設定される。 値が発生した場合は、エラーなので対象外にする */ @@ -316,4 +324,3 @@ } return 1; } -