Author: carnold
Date: Tue Jul 11 14:27:17 2006
New Revision: 420994
URL: http://svn.apache.org/viewvc?rev=420994&view=rev
Log:
LOGCXX-88: Use security-enhanced CRT methods if available
Modified:
logging/log4cxx/trunk/src/exception.cpp
logging/log4cxx/trunk/tests/src/helpers/charsetdecodertestcase.cpp
logging/log4cxx/trunk/tests/src/rolling/filterbasedrollingtest.cpp
Modified: logging/log4cxx/trunk/src/exception.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/exception.cpp?rev=420994&r1=420993&r2=420994&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/exception.cpp (original)
+++ logging/log4cxx/trunk/src/exception.cpp Tue Jul 11 14:27:17 2006
@@ -33,11 +33,19 @@
}
Exception::Exception(const Exception& src) {
- strcpy(msg, src.msg);
+#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
+ strcpy_s(msg, sizeof msg, src.msg);
+#else
+ strcpy(msg, src.msg);
+#endif
}
Exception& Exception::operator=(const Exception& src) {
- strcpy(msg, src.msg);
+#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
+ strcpy_s(msg, sizeof msg, src.msg);
+#else
+ strcpy(msg, src.msg);
+#endif
return *this;
}
Modified: logging/log4cxx/trunk/tests/src/helpers/charsetdecodertestcase.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/tests/src/helpers/charsetdecodertestcase.cpp?rev=420994&r1=420993&r2=420994&view=diff
==============================================================================
--- logging/log4cxx/trunk/tests/src/helpers/charsetdecodertestcase.cpp
(original)
+++ logging/log4cxx/trunk/tests/src/helpers/charsetdecodertestcase.cpp Tue Jul
11 14:27:17 2006
@@ -65,7 +65,12 @@
void decode2() {
char buf[BUFSIZE + 6];
memset(buf, 'A', BUFSIZE);
- strcpy(buf + BUFSIZE - 3, "Hello");
+ buf[BUFSIZE - 3] = 0;
+#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
+ strcat_s(buf, sizeof buf, "Hello");
+#else
+ strcat(buf, "Hello");
+#endif
ByteBuffer src(buf, strlen(buf));
CharsetDecoderPtr dec(CharsetDecoder::getDefaultDecoder());
@@ -108,7 +113,12 @@
for(int i = 0; i < BUFSIZE; i++) {
buf[i] = L'A';
}
- wcscpy(buf + BUFSIZE - 3, L"Hello");
+ buf[BUFSIZE - 3] = 0;
+#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
+ wcscat_s(buf, (sizeof buf)/sizeof(wchar_t), L"Hello");
+#else
+ wcscat(buf, L"Hello");
+#endif
ByteBuffer src((char*) buf, wcslen(buf) * sizeof(wchar_t));
CharsetDecoderPtr dec(CharsetDecoder::getWideDecoder());
Modified: logging/log4cxx/trunk/tests/src/rolling/filterbasedrollingtest.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/tests/src/rolling/filterbasedrollingtest.cpp?rev=420994&r1=420993&r2=420994&view=diff
==============================================================================
--- logging/log4cxx/trunk/tests/src/rolling/filterbasedrollingtest.cpp
(original)
+++ logging/log4cxx/trunk/tests/src/rolling/filterbasedrollingtest.cpp Tue Jul
11 14:27:17 2006
@@ -109,9 +109,12 @@
// Write exactly 10 bytes with each log
for (int i = 0; i < 25; i++) {
-
char msg[10];
+#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
+ strcpy_s(msg, sizeof msg, "Hello---?");
+#else
strcpy(msg, "Hello---?");
+#endif
if (i < 10) {
msg[8] = (char) ('0' + i);
LOG4CXX_DEBUG(logger, msg);