mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
- eitd: fix possible buffer overflow while writing egp-data (patch by FlatTV)
This commit is contained in:
@@ -1179,12 +1179,10 @@ static void commandWriteSI2XML(int connfd, char *data, const unsigned dataLength
|
|||||||
eventServer->sendEvent(CSectionsdClient::EVT_WRITE_SI_FINISHED, CEventServer::INITID_SECTIONSD);
|
eventServer->sendEvent(CSectionsdClient::EVT_WRITE_SI_FINISHED, CEventServer::INITID_SECTIONSD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char epgdir[100] = "";
|
|
||||||
|
|
||||||
strncpy(epgdir, data, dataLength);
|
data[dataLength] = '\0';
|
||||||
epgdir[dataLength] = '\0';
|
|
||||||
|
|
||||||
writeEventsToFile(epgdir);
|
writeEventsToFile(data);
|
||||||
|
|
||||||
eventServer->sendEvent(CSectionsdClient::EVT_WRITE_SI_FINISHED, CEventServer::INITID_SECTIONSD);
|
eventServer->sendEvent(CSectionsdClient::EVT_WRITE_SI_FINISHED, CEventServer::INITID_SECTIONSD);
|
||||||
}
|
}
|
||||||
|
@@ -448,24 +448,23 @@ static void write_indexxml_footer(FILE *fd)
|
|||||||
void writeEventsToFile(char *epgdir)
|
void writeEventsToFile(char *epgdir)
|
||||||
{
|
{
|
||||||
FILE * indexfile = NULL;
|
FILE * indexfile = NULL;
|
||||||
FILE * eventfile =NULL;
|
FILE * eventfile = NULL;
|
||||||
char filename[100] = "";
|
std::string filename("");
|
||||||
char tmpname[100] = "";
|
std::string tmpname("");
|
||||||
char eventname[17] = "";
|
char eventname[17] = "";
|
||||||
t_original_network_id onid = 0;
|
t_original_network_id onid = 0;
|
||||||
t_transport_stream_id tsid = 0;
|
t_transport_stream_id tsid = 0;
|
||||||
t_service_id sid = 0;
|
t_service_id sid = 0;
|
||||||
deleteOldfileEvents(epgdir);
|
deleteOldfileEvents(epgdir);
|
||||||
|
|
||||||
|
tmpname = (std::string)epgdir + "/index.tmp";
|
||||||
|
|
||||||
sprintf(tmpname, "%s/index.tmp", epgdir);
|
if (!(indexfile = fopen(tmpname.c_str(), "w"))) {
|
||||||
|
printf("[sectionsd] unable to open %s for writing\n", tmpname.c_str());
|
||||||
if (!(indexfile = fopen(tmpname, "w"))) {
|
|
||||||
printf("[sectionsd] unable to open %s for writing\n", tmpname);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[sectionsd] Writing Information to file: %s\n", tmpname);
|
printf("[sectionsd] Writing Information to file: %s\n", tmpname.c_str());
|
||||||
|
|
||||||
write_index_xml_header(indexfile);
|
write_index_xml_header(indexfile);
|
||||||
|
|
||||||
@@ -483,8 +482,8 @@ void writeEventsToFile(char *epgdir)
|
|||||||
tsid = (*e)->transport_stream_id;
|
tsid = (*e)->transport_stream_id;
|
||||||
sid = (*e)->service_id;
|
sid = (*e)->service_id;
|
||||||
snprintf(eventname, 17, "%04x%04x%04x.xml", onid, tsid, sid);
|
snprintf(eventname, 17, "%04x%04x%04x.xml", onid, tsid, sid);
|
||||||
sprintf(filename, "%s/%s", epgdir, eventname);
|
filename = (std::string)epgdir + "/" + (std::string)eventname;
|
||||||
if (!(eventfile = fopen(filename, "w"))) {
|
if (!(eventfile = fopen(filename.c_str(), "w"))) {
|
||||||
goto _done;
|
goto _done;
|
||||||
}
|
}
|
||||||
fprintf(indexfile, "\t<eventfile name=\"%s\"/>\n", eventname);
|
fprintf(indexfile, "\t<eventfile name=\"%s\"/>\n", eventname);
|
||||||
@@ -501,9 +500,9 @@ _done:
|
|||||||
|
|
||||||
printf("[sectionsd] Writing Information finished\n");
|
printf("[sectionsd] Writing Information finished\n");
|
||||||
|
|
||||||
sprintf(filename, "%s/index.xml", epgdir);
|
filename = (std::string)epgdir + "/index.xml";
|
||||||
|
|
||||||
rename(tmpname, filename);
|
rename(tmpname.c_str(), filename.c_str());
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user