From ef439c14d382b18a4e5f7f8510f8c7b90aa84d87 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 31 Mar 2015 14:44:41 +0200 Subject: [PATCH] nhttpd: change sprintf to snprintf Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/0f2ac568c899a3d267d7a6ae8b2077648aa55413 Author: Jacek Jendrzej Date: 2015-03-31 (Tue, 31 Mar 2015) Origin message was: ------------------ nhttpd: change sprintf to snprintf --- src/nhttpd/tuxboxapi/coolstream/controlapi.cpp | 4 ++-- src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp | 4 ++-- src/nhttpd/yhttpd_core/helper.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 39a19d06e..97657d516 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -1958,7 +1958,7 @@ void CControlAPI::SendTimers(CyhookHandler *hh) "Unknown TV-Channel" : "Unknown Radio-Channel"); } else - sprintf(zAddData, PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer->channel_id); + snprintf(zAddData,sizeof(zAddData), PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer->channel_id); zAddData[22]=0; @@ -1966,7 +1966,7 @@ void CControlAPI::SendTimers(CyhookHandler *hh) case CTimerd::TIMER_STANDBY: if (!send_id) - sprintf(zAddData,"Standby: %s",(timer->standby_on ? "ON" : "OFF")); + snprintf(zAddData,sizeof(zAddData),"Standby: %s",(timer->standby_on ? "ON" : "OFF")); break; case CTimerd::TIMER_REMIND : diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp index a71848bc5..e65986b40 100644 --- a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp @@ -300,11 +300,11 @@ std::string CNeutrinoYParser::func_get_channels_as_dropdown(CyhookHandler *, st CEPGData epg; CZapitChannel * channel = channels[j]; char buf[100],id[20]; - sprintf(id,PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS,channel->getChannelID()); + snprintf(id,sizeof(id),PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS,channel->getChannelID()); std::string _sid = std::string(id); sel = (_sid == achannel_id) ? "selected=\"selected\"" : ""; CEitManager::getInstance()->getActualEPGServiceKey(channel->getChannelID(), &epg); - sprintf(buf,"\n", channel->getChannelID(), sel.c_str(), channel->getName().c_str(),epg.title.c_str()); + snprintf(buf,sizeof(buf),"\n", channel->getChannelID(), sel.c_str(), channel->getName().c_str(),epg.title.c_str()); yresult += buf; } } diff --git a/src/nhttpd/yhttpd_core/helper.cpp b/src/nhttpd/yhttpd_core/helper.cpp index d8a6630aa..fc1d7ba0a 100644 --- a/src/nhttpd/yhttpd_core/helper.cpp +++ b/src/nhttpd/yhttpd_core/helper.cpp @@ -229,7 +229,7 @@ std::string encodeString(std::string decodedString) { if (isalnum(one_char)) *newString++ = one_char; else - newString += sprintf(newString, "&#%d;", + newString += snprintf(newString,result.length(), "&#%d;", (unsigned char) one_char); }