File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -321,19 +321,19 @@ void IWriter::w_sdir(const Fvector& D)
321321 w_dir (C);
322322 w_float (mag);
323323}
324+ // XXX: reimplement to prevent buffer overflows
324325void IWriter::w_printf (const char * format, ...)
325326{
326- va_list mark;
327- char buf[1024 ];
328-
329- va_start (mark, format);
330- #ifndef _EDITOR
331- vsprintf_s (buf, format, mark);
332- #else
333- vsprintf (buf, format, mark);
334- #endif
335- va_end (mark);
327+ va_list args;
328+ va_start (args, format);
329+ VPrintf (format, args);
330+ va_end (args);
331+ }
336332
333+ void IWriter::VPrintf (const char *format, va_list args)
334+ {
335+ char buf[1024 ];
336+ std::vsnprintf (buf, sizeof (buf), format, args);
337337 w (buf, xr_strlen (buf));
338338}
339339
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class XRCORE_API IWriter
8585 IC void w_dir (const Fvector& D) { w_u16 (pvCompress (D)); }
8686 void w_sdir (const Fvector& D);
8787 void __cdecl w_printf (const char * format, ...);
88+ void VPrintf (const char *format, va_list args);
8889
8990 // generalized chunking
9091 u32 align ();
You can’t perform that action at this time.
0 commit comments