Skip to content

Commit

Permalink
Add IWriter::VPrintf function.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Dec 12, 2015
1 parent 91f03a8 commit 77ed999
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/xrCore/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,19 @@ void IWriter::w_sdir(const Fvector& D)
w_dir(C);
w_float(mag);
}
// XXX: reimplement to prevent buffer overflows
void IWriter::w_printf(const char* format, ...)
{
va_list mark;
char buf[1024];

va_start(mark, format);
#ifndef _EDITOR
vsprintf_s(buf, format, mark);
#else
vsprintf(buf, format, mark);
#endif
va_end(mark);
va_list args;
va_start(args, format);
VPrintf(format, args);
va_end(args);
}

void IWriter::VPrintf(const char *format, va_list args)
{
char buf[1024];
std::vsnprintf(buf, sizeof(buf), format, args);
w(buf, xr_strlen(buf));
}

Expand Down
1 change: 1 addition & 0 deletions src/xrCore/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class XRCORE_API IWriter
IC void w_dir(const Fvector& D) { w_u16(pvCompress(D)); }
void w_sdir(const Fvector& D);
void __cdecl w_printf(const char* format, ...);
void VPrintf(const char *format, va_list args);

// generalized chunking
u32 align();
Expand Down

0 comments on commit 77ed999

Please sign in to comment.