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
This commit is contained in:
satbaby
2011-12-26 11:03:40 +00:00
parent bab93b46ac
commit bed601438e
5 changed files with 27 additions and 26 deletions

View File

@@ -502,7 +502,8 @@ void CRemoteControl::processAPIDnames()
if ( current_PIDs.APIDs[count].is_ac3 ) 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; has_ac3 = true;
if((strlen( current_PIDs.APIDs[count].desc ) == 3) && g_settings.audio_DolbyDigital && (ac3_found < 0)) if((strlen( current_PIDs.APIDs[count].desc ) == 3) && g_settings.audio_DolbyDigital && (ac3_found < 0))
ac3_found = count; ac3_found = count;
@@ -528,11 +529,11 @@ void CRemoteControl::processAPIDnames()
// workaround for buggy ZDF ctags / or buggy sectionsd/drivers , who knows... // workaround for buggy ZDF ctags / or buggy sectionsd/drivers , who knows...
if(!tags[i].component.empty()) if(!tags[i].component.empty())
{ {
strncpy(current_PIDs.APIDs[j].desc, tags[i].component.c_str(), 25); strncpy(current_PIDs.APIDs[j].desc, tags[i].component.c_str(), DESC_MAX_LEN);
if (current_PIDs.APIDs[j].is_ac3) if (current_PIDs.APIDs[j].is_ac3 && !strstr(current_PIDs.APIDs[j].desc, " (AC3)"))
strncat(current_PIDs.APIDs[j].desc, " (AC3)", 25); strncat(current_PIDs.APIDs[j].desc, " (AC3)", DESC_MAX_LEN - strlen(current_PIDs.APIDs[j].desc));
else if (current_PIDs.APIDs[j].is_aac) else if (current_PIDs.APIDs[j].is_aac && !strstr(current_PIDs.APIDs[j].desc, " (AAC)"))
strncat(current_PIDs.APIDs[j].desc, " (AAC)", 25); strncat(current_PIDs.APIDs[j].desc, " (AAC)", DESC_MAX_LEN - strlen(current_PIDs.APIDs[j].desc));
} }
current_PIDs.APIDs[j].component_tag = -1; current_PIDs.APIDs[j].component_tag = -1;
break; break;

View File

@@ -321,7 +321,7 @@ void CRecordInstance::GetPids(CZapitChannel * channel)
for (uint32_t i = 0; i < channel->getAudioChannelCount(); i++) { for (uint32_t i = 0; i < channel->getAudioChannelCount(); i++) {
CZapitClient::responseGetAPIDs response; CZapitClient::responseGetAPIDs response;
response.pid = channel->getAudioPid(i); 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; response.is_ac3 = response.is_aac = 0;
if (channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) { if (channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) {
response.is_ac3 = 1; response.is_ac3 = 1;
@@ -344,12 +344,12 @@ void CRecordInstance::ProcessAPIDnames()
has_unresolved_ctags= true; has_unresolved_ctags= true;
if ( strlen( allpids.APIDs[count].desc ) == 3 ) 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 ) if ( allpids.APIDs[count].is_ac3 && !strstr(allpids.APIDs[count].desc, " (AC3)"))
strncat(allpids.APIDs[count].desc, " (AC3)", 25); strncat(allpids.APIDs[count].desc, " (AC3)", DESC_MAX_LEN - strlen(allpids.APIDs[count].desc));
else if (allpids.APIDs[count].is_aac) else if (allpids.APIDs[count].is_aac && !strstr(allpids.APIDs[count].desc, " (AAC)"))
strncat(allpids.APIDs[count].desc, " (AAC)", 25); strncat(allpids.APIDs[count].desc, " (AAC)", DESC_MAX_LEN - strlen(allpids.APIDs[count].desc));
} }
if(has_unresolved_ctags && (epgid != 0)) { if(has_unresolved_ctags && (epgid != 0)) {
@@ -359,11 +359,11 @@ void CRecordInstance::ProcessAPIDnames()
for(unsigned int j=0; j< allpids.APIDs.size(); j++) { for(unsigned int j=0; j< allpids.APIDs.size(); j++) {
if(allpids.APIDs[j].component_tag == tags[i].componentTag) { if(allpids.APIDs[j].component_tag == tags[i].componentTag) {
if(!tags[i].component.empty()) { if(!tags[i].component.empty()) {
strncpy(allpids.APIDs[j].desc, tags[i].component.c_str(), 25); strncpy(allpids.APIDs[j].desc, tags[i].component.c_str(), DESC_MAX_LEN);
if (allpids.APIDs[j].is_ac3) if (allpids.APIDs[j].is_ac3 && !strstr(allpids.APIDs[j].desc, " (AC3)"))
strncat(allpids.APIDs[j].desc, " (AC3)", 25); strncat(allpids.APIDs[j].desc, " (AC3)", DESC_MAX_LEN - strlen(allpids.APIDs[j].desc));
else if (allpids.APIDs[j].is_aac) else if (allpids.APIDs[j].is_aac && !strstr(allpids.APIDs[j].desc, " (AAC)"))
strncat(allpids.APIDs[j].desc, " (AAC)", 25); strncat(allpids.APIDs[j].desc, " (AAC)", DESC_MAX_LEN - strlen(allpids.APIDs[j].desc));
} }
allpids.APIDs[j].component_tag = -1; allpids.APIDs[j].component_tag = -1;
break; break;
@@ -601,16 +601,16 @@ record_error_msg_t CRecordInstance::MakeFileName(CZapitChannel * channel)
if (errno == ENOENT) { if (errno == ENOENT) {
res = safe_mkdir(filename); res = safe_mkdir(filename);
if (res == 0) if (res == 0)
strcat(filename,"/"); strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename));
else else
perror("[vcrcontrol] mkdir"); perror("[vcrcontrol] mkdir");
} else } else
perror("[vcrcontrol] stat"); perror("[vcrcontrol] stat");
} else } else
// directory exists // directory exists
strcat(filename,"/"); strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename));
} else } else
strcat(filename, "_"); strncat(filename, "_",FILENAMEBUFFERSIZE - strlen(filename));
} }
pos = 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)); pos += strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t));
if(autoshift) if(autoshift)
strcat(filename, "_temp"); strncat(filename, "_temp",FILENAMEBUFFERSIZE - strlen(filename));
return RECORD_OK; return RECORD_OK;
} }

View File

@@ -1647,7 +1647,7 @@ void CControlAPI::SendAllCurrentVAPid(CyhookHandler *hh)
{ {
if(!(init_iso)) 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)": " "); 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)) 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)": " "); hh->printf("%05u %s %s\n",it->pid,pids.APIDs[i].desc,pids.APIDs[i].is_ac3 ? " (AC3)": " ");
i++; i++;

View File

@@ -175,11 +175,11 @@ class CZapitClient:public CBasicClient
{}; {};
typedef std::vector<responseGetBouquetNChannels> BouquetNChannelList; typedef std::vector<responseGetBouquetNChannels> BouquetNChannelList;
#define DESC_MAX_LEN 38 //component descriptor name length + " (AC3)"
struct responseGetAPIDs struct responseGetAPIDs
{ {
uint32_t pid; uint32_t pid;
char desc[25]; char desc[DESC_MAX_LEN];
int is_ac3; int is_ac3;
int is_aac; int is_aac;
int component_tag; int component_tag;

View File

@@ -1587,7 +1587,7 @@ void CZapit::sendAPIDs(int connfd)
for (uint32_t i = 0; i < current_channel->getAudioChannelCount(); i++) { for (uint32_t i = 0; i < current_channel->getAudioChannelCount(); i++) {
CZapitClient::responseGetAPIDs response; CZapitClient::responseGetAPIDs response;
response.pid = current_channel->getAudioPid(i); 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; response.is_ac3 = response.is_aac = 0;
if (current_channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) { if (current_channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) {
response.is_ac3 = 1; response.is_ac3 = 1;