Fix for buffer overflow, WebRTC issue 1196

Review URL: https://webrtc-codereview.appspot.com/998004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3286 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
elham@webrtc.org 2012-12-13 21:55:47 +00:00
parent 96dc6270d4
commit ddebc17bee

View File

@ -14,6 +14,7 @@
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <sstream>
namespace webrtc {
@ -53,9 +54,9 @@ std::string ChoiceBuilder::MakeHumanReadableOptions() {
std::string result = "";
Choices::const_iterator iterator = choices_.begin();
for (int number = 1; iterator != choices_.end(); ++iterator, ++number) {
char buffer[128];
sprintf(buffer, "\n %d. %s", number, (*iterator).c_str());
result += buffer;
std::ostringstream os;
os << "\n " << number << ". " << (*iterator).c_str();
result += os.str();
}
return result;
}