[スレッド全体]

2016/11/30 (水) 16:31:39 もか  
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
[2388] Re5:セキュアなsnprintf関数。
それ以前の問題として、サクラの定義をよく見てみると、数か所間違いがあるようにみえます。
defineのほうはrev:3680以降からです。
こうじゃないでしょうか。

Index: sakura_core/util/string_ex.h
===================================================================
--- sakura_core/util/string_ex.h	(リビジョン 4157)
+++ sakura_core/util/string_ex.h	(作業コピー)
@@ -253,9 +253,9 @@
 
 //印字系
 #if defined(_MSC_VER) && _MSC_VER>=1400
-#define auto_snprintf_s(buf, count, format, ...) tchar_sprintf_s((buf), count, (format), __VA_ARGS__)
+#define auto_snprintf_s(buf, count, format, ...) tchar_snprintf_s((buf), count, (format), __VA_ARGS__)
 #define auto_sprintf(buf, format, ...)           tchar_sprintf((buf), (format), __VA_ARGS__)
-#define auto_sprintf_s(buf, nBufCount, format, ...) tchar_snprintf_s((buf), nBufCount, (format), __VA_ARGS__)
+#define auto_sprintf_s(buf, nBufCount, format, ...) tchar_sprintf_s((buf), nBufCount, (format), __VA_ARGS__)
 #else
(すみません省略します)
Index: sakura_core/util/tchar_printf.cpp
===================================================================
--- sakura_core/util/tchar_printf.cpp	(リビジョン 4157)
+++ sakura_core/util/tchar_printf.cpp	(作業コピー)
@@ -359,6 +359,7 @@
 
 
 // sprintf_sラップ
+// ※nBufCountをはみ出す場合は異常終了します。
 //
 // (実装について)
 //     内容が同じなので、templateでも良かったのですが、
@@ -418,7 +419,7 @@
 {
 	va_list v;
 	va_start(v,format);
-	int ret=tchar_vsprintf_s(buf,count,format,v);
+	int ret=tchar_vsnprintf_s(buf,count,format,v);
 	va_end(v);
 	return ret;
 }
@@ -426,7 +427,7 @@
 {
 	va_list v;
 	va_start(v,format);
-	int ret=tchar_vsprintf_s(buf,count,format,v);
+	int ret=tchar_vsnprintf_s(buf,count,format,v);
 	va_end(v);
 	return ret;
 }

[▼次のスレッド]
INCM/CMT
Cyclamen v3.81
[ut:0.000][st:0.000]