Change sprintf use in talk samples to snprintf
BUG=2301 R=juberti@webrtc.org Review URL: https://webrtc-codereview.appspot.com/41579004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8128 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
ea1c84285c
commit
b40c7bb53c
@ -35,6 +35,9 @@
|
||||
|
||||
#include "talk/examples/peerconnection/server/data_socket.h"
|
||||
#include "talk/examples/peerconnection/server/utils.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
|
||||
using rtc::sprintfn;
|
||||
|
||||
// Set to the peer id of the originator when messages are being
|
||||
// exchanged between peers, but set to the id of the receiving peer
|
||||
@ -108,8 +111,11 @@ bool ChannelMember::NotifyOfOtherMember(const ChannelMember& other) {
|
||||
// Returns a string in the form "name,id,connected\n".
|
||||
std::string ChannelMember::GetEntry() const {
|
||||
assert(name_.length() <= kMaxNameLength);
|
||||
char entry[1024] = {0};
|
||||
sprintf(entry, "%s,%i,%i\n", name_.c_str(), id_, connected_); // NOLINT
|
||||
|
||||
// name, 11-digit int, 1-digit bool, newline, null
|
||||
char entry[kMaxNameLength + 15];
|
||||
sprintfn(entry, sizeof(entry), "%s%d%d\n",
|
||||
name_.substr(0, kMaxNameLength).c_str(), id_, connected_);
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@ -29,19 +29,14 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "webrtc/base/stringencode.h"
|
||||
|
||||
using rtc::ToString;
|
||||
|
||||
std::string int2str(int i) {
|
||||
char buffer[11] = {0};
|
||||
sprintf(buffer, "%d", i); // NOLINT
|
||||
return buffer;
|
||||
return ToString<int>(i);
|
||||
}
|
||||
|
||||
std::string size_t2str(size_t i) {
|
||||
char buffer[32] = {0};
|
||||
#ifdef WIN32
|
||||
// %zu isn't supported on Windows.
|
||||
sprintf(buffer, "%Iu", i); // NOLINT
|
||||
#else
|
||||
sprintf(buffer, "%zu", i); // NOLINT
|
||||
#endif
|
||||
return buffer;
|
||||
return ToString<size_t>(i);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user