mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 09:51:22 +02:00
-fixes strncpy & buf size
This commit is contained in:
@@ -1059,6 +1059,7 @@ FILE *f_open(const char *filename, const char *acctype)
|
||||
for(int i=0; ((ptr != NULL) && (i<25)); ptr = strstr(ptr, "http://") )
|
||||
{
|
||||
strncpy(servers[i], ptr, 1023);
|
||||
servers[i][1023] = '\0';
|
||||
ptr2 = strchr(servers[i], '\n');
|
||||
if(ptr2) *ptr2 = 0;
|
||||
// change ptr so that next strstr searches in buf and not in servers[i]
|
||||
@@ -1300,6 +1301,7 @@ const char *f_type(FILE *stream, const char *type)
|
||||
{
|
||||
stream_type[i].stream = stream;
|
||||
strncpy(stream_type[i].type, type, 64);
|
||||
stream_type[i].type[64] = '\0';
|
||||
dprintf(stderr, "added entry (%s) for %p\n", type, stream);
|
||||
}
|
||||
return type;
|
||||
@@ -1720,7 +1722,8 @@ void ShoutCAST_ParseMetaData(char *md, CSTATE *state)
|
||||
if(!ptr)
|
||||
{
|
||||
ptr = strchr(md, '=');
|
||||
strncpy(state->title, ptr + 2, 4096);
|
||||
strncpy(state->title, ptr + 2, 4095);
|
||||
state->title[4095] = '\0';
|
||||
ptr = strchr(state->title, ';');
|
||||
if(ptr)
|
||||
*(ptr - 1) = 0;
|
||||
@@ -1736,7 +1739,8 @@ void ShoutCAST_ParseMetaData(char *md, CSTATE *state)
|
||||
|
||||
ptr = strstr(md, "StreamTitle=");
|
||||
ptr = strchr(ptr, '\'');
|
||||
strncpy(state->artist, ptr + 1, 4096);
|
||||
strncpy(state->artist, ptr + 1, 4095);
|
||||
state->artist[4095] = '\0';
|
||||
ptr = strstr(state->artist, " - ");
|
||||
if(!ptr)
|
||||
ptr = strstr(state->artist, ", ");
|
||||
|
@@ -320,7 +320,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(), DESC_MAX_LEN);
|
||||
strncpy(response.desc, channel->getAudioChannel(i)->description.c_str(), DESC_MAX_LEN - 1);
|
||||
response.is_ac3 = response.is_aac = 0;
|
||||
if (channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) {
|
||||
response.is_ac3 = 1;
|
||||
@@ -343,12 +343,12 @@ void CRecordInstance::ProcessAPIDnames()
|
||||
has_unresolved_ctags= true;
|
||||
|
||||
if ( strlen( allpids.APIDs[count].desc ) == 3 )
|
||||
strncpy( allpids.APIDs[count].desc, getISO639Description( allpids.APIDs[count].desc ),DESC_MAX_LEN );
|
||||
strncpy( allpids.APIDs[count].desc, getISO639Description( allpids.APIDs[count].desc ),DESC_MAX_LEN -1 );
|
||||
|
||||
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));
|
||||
strncat(allpids.APIDs[count].desc, " (AC3)", DESC_MAX_LEN - strlen(allpids.APIDs[count].desc) -1);
|
||||
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));
|
||||
strncat(allpids.APIDs[count].desc, " (AAC)", DESC_MAX_LEN - strlen(allpids.APIDs[count].desc) -1);
|
||||
}
|
||||
|
||||
if(has_unresolved_ctags && (epgid != 0)) {
|
||||
@@ -358,11 +358,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(), DESC_MAX_LEN);
|
||||
strncpy(allpids.APIDs[j].desc, tags[i].component.c_str(), DESC_MAX_LEN -1);
|
||||
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));
|
||||
strncat(allpids.APIDs[j].desc, " (AC3)", DESC_MAX_LEN - strlen(allpids.APIDs[j].desc)-1);
|
||||
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));
|
||||
strncat(allpids.APIDs[j].desc, " (AAC)", DESC_MAX_LEN - strlen(allpids.APIDs[j].desc)-1);
|
||||
}
|
||||
allpids.APIDs[j].component_tag = -1;
|
||||
break;
|
||||
@@ -598,16 +598,16 @@ record_error_msg_t CRecordInstance::MakeFileName(CZapitChannel * channel)
|
||||
if (errno == ENOENT) {
|
||||
res = safe_mkdir(filename);
|
||||
if (res == 0)
|
||||
strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename));
|
||||
strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename) -1);
|
||||
else
|
||||
perror("[vcrcontrol] mkdir");
|
||||
} else
|
||||
perror("[vcrcontrol] stat");
|
||||
} else
|
||||
// directory exists
|
||||
strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename));
|
||||
strncat(filename,"/",FILENAMEBUFFERSIZE - strlen(filename)-1);
|
||||
} else
|
||||
strncat(filename, "_",FILENAMEBUFFERSIZE - strlen(filename));
|
||||
strncat(filename, "_",FILENAMEBUFFERSIZE - strlen(filename)-1);
|
||||
}
|
||||
|
||||
pos = strlen(filename);
|
||||
@@ -631,7 +631,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)
|
||||
strncat(filename, "_temp",FILENAMEBUFFERSIZE - strlen(filename));
|
||||
strncat(filename, "_temp",FILENAMEBUFFERSIZE - strlen(filename)-1);
|
||||
|
||||
return RECORD_OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user