From bed601438eb44f21cc905ced44d39662dc3ad6cf Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 26 Dec 2011 11:03:40 +0000 Subject: [PATCH] safter strncat & enlarged audio descriptor name length git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@2005 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/daemonc/remotecontrol.cpp | 13 ++++---- src/driver/record.cpp | 30 +++++++++---------- .../tuxboxapi/coolstream/controlapi.cpp | 4 +-- src/zapit/include/zapit/client/zapitclient.h | 4 +-- src/zapit/src/zapit.cpp | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index 365ae2d16..0092df048 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -502,7 +502,8 @@ void CRemoteControl::processAPIDnames() if ( current_PIDs.APIDs[count].is_ac3 ) { - strncat(current_PIDs.APIDs[count].desc, " (AC3)", 25); + if(!strstr(current_PIDs.APIDs[count].desc, " (AC3)")) + strncat(current_PIDs.APIDs[count].desc, " (AC3)", DESC_MAX_LEN - strlen(current_PIDs.APIDs[count].desc)); has_ac3 = true; if((strlen( current_PIDs.APIDs[count].desc ) == 3) && g_settings.audio_DolbyDigital && (ac3_found < 0)) ac3_found = count; @@ -528,11 +529,11 @@ void CRemoteControl::processAPIDnames() // workaround for buggy ZDF ctags / or buggy sectionsd/drivers , who knows... if(!tags[i].component.empty()) { - strncpy(current_PIDs.APIDs[j].desc, tags[i].component.c_str(), 25); - if (current_PIDs.APIDs[j].is_ac3) - strncat(current_PIDs.APIDs[j].desc, " (AC3)", 25); - else if (current_PIDs.APIDs[j].is_aac) - strncat(current_PIDs.APIDs[j].desc, " (AAC)", 25); + strncpy(current_PIDs.APIDs[j].desc, tags[i].component.c_str(), DESC_MAX_LEN); + if (current_PIDs.APIDs[j].is_ac3 && !strstr(current_PIDs.APIDs[j].desc, " (AC3)")) + strncat(current_PIDs.APIDs[j].desc, " (AC3)", DESC_MAX_LEN - strlen(current_PIDs.APIDs[j].desc)); + else if (current_PIDs.APIDs[j].is_aac && !strstr(current_PIDs.APIDs[j].desc, " (AAC)")) + strncat(current_PIDs.APIDs[j].desc, " (AAC)", DESC_MAX_LEN - strlen(current_PIDs.APIDs[j].desc)); } current_PIDs.APIDs[j].component_tag = -1; break; diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 94a1cf92d..8154e01e0 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -321,7 +321,7 @@ void CRecordInstance::GetPids(CZapitChannel * channel) for (uint32_t i = 0; i < channel->getAudioChannelCount(); i++) { CZapitClient::responseGetAPIDs response; response.pid = channel->getAudioPid(i); - strncpy(response.desc, channel->getAudioChannel(i)->description.c_str(), 25); + strncpy(response.desc, channel->getAudioChannel(i)->description.c_str(), DESC_MAX_LEN); response.is_ac3 = response.is_aac = 0; if (channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) { response.is_ac3 = 1; @@ -344,12 +344,12 @@ void CRecordInstance::ProcessAPIDnames() has_unresolved_ctags= true; if ( strlen( allpids.APIDs[count].desc ) == 3 ) - strcpy( allpids.APIDs[count].desc, getISO639Description( allpids.APIDs[count].desc ) ); + strncpy( allpids.APIDs[count].desc, getISO639Description( allpids.APIDs[count].desc ),DESC_MAX_LEN ); - if ( allpids.APIDs[count].is_ac3 ) - strncat(allpids.APIDs[count].desc, " (AC3)", 25); - else if (allpids.APIDs[count].is_aac) - strncat(allpids.APIDs[count].desc, " (AAC)", 25); + if ( allpids.APIDs[count].is_ac3 && !strstr(allpids.APIDs[count].desc, " (AC3)")) + strncat(allpids.APIDs[count].desc, " (AC3)", DESC_MAX_LEN - strlen(allpids.APIDs[count].desc)); + else if (allpids.APIDs[count].is_aac && !strstr(allpids.APIDs[count].desc, " (AAC)")) + strncat(allpids.APIDs[count].desc, " (AAC)", DESC_MAX_LEN - strlen(allpids.APIDs[count].desc)); } if(has_unresolved_ctags && (epgid != 0)) { @@ -359,11 +359,11 @@ void CRecordInstance::ProcessAPIDnames() for(unsigned int j=0; j< allpids.APIDs.size(); j++) { if(allpids.APIDs[j].component_tag == tags[i].componentTag) { if(!tags[i].component.empty()) { - strncpy(allpids.APIDs[j].desc, tags[i].component.c_str(), 25); - if (allpids.APIDs[j].is_ac3) - strncat(allpids.APIDs[j].desc, " (AC3)", 25); - else if (allpids.APIDs[j].is_aac) - strncat(allpids.APIDs[j].desc, " (AAC)", 25); + strncpy(allpids.APIDs[j].desc, tags[i].component.c_str(), DESC_MAX_LEN); + if (allpids.APIDs[j].is_ac3 && !strstr(allpids.APIDs[j].desc, " (AC3)")) + strncat(allpids.APIDs[j].desc, " (AC3)", DESC_MAX_LEN - strlen(allpids.APIDs[j].desc)); + else if (allpids.APIDs[j].is_aac && !strstr(allpids.APIDs[j].desc, " (AAC)")) + strncat(allpids.APIDs[j].desc, " (AAC)", DESC_MAX_LEN - strlen(allpids.APIDs[j].desc)); } allpids.APIDs[j].component_tag = -1; break; @@ -601,16 +601,16 @@ record_error_msg_t CRecordInstance::MakeFileName(CZapitChannel * channel) if (errno == ENOENT) { res = safe_mkdir(filename); if (res == 0) - strcat(filename,"/"); + strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename)); else perror("[vcrcontrol] mkdir"); } else perror("[vcrcontrol] stat"); } else // directory exists - strcat(filename,"/"); + strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename)); } else - strcat(filename, "_"); + strncat(filename, "_",FILENAMEBUFFERSIZE - strlen(filename)); } pos = strlen(filename); @@ -634,7 +634,7 @@ record_error_msg_t CRecordInstance::MakeFileName(CZapitChannel * channel) pos += strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t)); if(autoshift) - strcat(filename, "_temp"); + strncat(filename, "_temp",FILENAMEBUFFERSIZE - strlen(filename)); return RECORD_OK; } diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index c90687242..02fbee42a 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -1647,7 +1647,7 @@ void CControlAPI::SendAllCurrentVAPid(CyhookHandler *hh) { if(!(init_iso)) { - strcpy( pids.APIDs[j].desc, _getISO639Description( pids.APIDs[j].desc ) ); + strncpy( pids.APIDs[j].desc, _getISO639Description( pids.APIDs[j].desc ),DESC_MAX_LEN ); } hh->printf("%05u %s %s\n",pids.APIDs[j].pid,pids.APIDs[j].desc,pids.APIDs[j].is_ac3 ? " (AC3)": " "); } @@ -1664,7 +1664,7 @@ void CControlAPI::SendAllCurrentVAPid(CyhookHandler *hh) { if(!(init_iso)) { - strcpy( pids.APIDs[i].desc, _getISO639Description( pids.APIDs[i].desc ) ); + strncpy( pids.APIDs[i].desc, _getISO639Description( pids.APIDs[i].desc ),DESC_MAX_LEN ); } hh->printf("%05u %s %s\n",it->pid,pids.APIDs[i].desc,pids.APIDs[i].is_ac3 ? " (AC3)": " "); i++; diff --git a/src/zapit/include/zapit/client/zapitclient.h b/src/zapit/include/zapit/client/zapitclient.h index f5818af53..1c160ca21 100644 --- a/src/zapit/include/zapit/client/zapitclient.h +++ b/src/zapit/include/zapit/client/zapitclient.h @@ -175,11 +175,11 @@ class CZapitClient:public CBasicClient {}; typedef std::vector BouquetNChannelList; - +#define DESC_MAX_LEN 38 //component descriptor name length + " (AC3)" struct responseGetAPIDs { uint32_t pid; - char desc[25]; + char desc[DESC_MAX_LEN]; int is_ac3; int is_aac; int component_tag; diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index ce155eefe..c2764aef5 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -1587,7 +1587,7 @@ void CZapit::sendAPIDs(int connfd) for (uint32_t i = 0; i < current_channel->getAudioChannelCount(); i++) { CZapitClient::responseGetAPIDs response; response.pid = current_channel->getAudioPid(i); - strncpy(response.desc, current_channel->getAudioChannel(i)->description.c_str(), 25); + strncpy(response.desc, current_channel->getAudioChannel(i)->description.c_str(), DESC_MAX_LEN); response.is_ac3 = response.is_aac = 0; if (current_channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) { response.is_ac3 = 1;