sprintf_s1

svn path=/trunk/; revision=19776
This commit is contained in:
Martin Fuchs
2005-11-30 14:02:55 +00:00
parent 84de2f0d6d
commit de00331be1
3 changed files with 11 additions and 2 deletions
@@ -166,6 +166,7 @@ BOOL exists_path(LPCTSTR path);
#endif
// secure CRT functions
#ifdef __STDC_WANT_SECURE_LIB__ // for VS 2005: _MSC_VER>=1400
#undef _vsntprintf
@@ -464,7 +464,7 @@ std::string XMLReaderBase::get_error_string() const
std::string EncodeXMLString(const XS_String& str)
{
LPCXSSTR s = str.c_str();
LPXSSTR buffer = (LPXSSTR)alloca(5*sizeof(XS_CHAR)*XS_len(s)); // worst case. "&"
LPXSSTR buffer = (LPXSSTR)alloca(6*sizeof(XS_CHAR)*XS_len(s)); // worst case """ / "'"
LPXSSTR o = buffer;
for(LPCXSSTR p=s; *p; ++p)
@@ -492,7 +492,7 @@ std::string EncodeXMLString(const XS_String& str)
default:
if ((unsigned)*p<20 && *p!='\t' && *p!='\r' && *p!='\n') {
char b[16];
sprintf(b, "&%d;", (unsigned)*p);
sprintf_s1(b, COUNTOF(b), "&%d;", (unsigned)*p);
for(const char*q=b; *q; )
*o++ = *q++;
} else
@@ -71,6 +71,14 @@
namespace XMLStorage {
// secure CRT functions
#ifdef __STDC_WANT_SECURE_LIB__ // VS 2005
#define sprintf_s1 sprintf_s
#else
#define sprintf_s1(b, l, f, p1) sprintf(b, f, p1)
#endif
#ifndef XS_String
#ifdef XS_STRING_UTF8