snprintf fix

This commit is contained in:
Arvid Norberg 2009-04-07 01:14:12 +00:00
parent c23fda2e2a
commit 970ab50e57
2 changed files with 5 additions and 5 deletions

View File

@ -142,8 +142,8 @@ namespace libtorrent
virtual char const* what() const { return "file renamed"; }
virtual std::string message() const
{
char msg[200];
snprintf(msg, 200, "%s: file %d renamed to %s", torrent_alert::message().c_str()
char msg[200 + NAME_MAX];
snprintf(msg, sizeof(msg), "%s: file %d renamed to %s", torrent_alert::message().c_str()
, index, name.c_str());
return msg;
}
@ -168,8 +168,8 @@ namespace libtorrent
virtual char const* what() const { return "file rename failed"; }
virtual std::string message() const
{
char ret[200];
snprintf(ret, 200, "%s: failed to rename file %d: %s"
char ret[200 + NAME_MAX];
snprintf(ret, sizeof(msg), "%s: failed to rename file %d: %s"
, torrent_alert::message().c_str(), index, msg.c_str());
return ret;
}

View File

@ -102,7 +102,7 @@ POSSIBILITY OF SUCH DAMAGE.
// this is the maximum number of characters in a
// path element / filename on windows
#define NAME_MAX 255
#define snprintf _snprintf_s
#define snprintf _snprintf
#define strtoll _strtoi64
#endif