diff options
author | rubidium <rubidium@openttd.org> | 2014-09-06 19:28:09 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-09-06 19:28:09 +0000 |
commit | 962c1a3242e213a65078ed4217112978ddb0c613 (patch) | |
tree | 6e4f30157cab540e39ba24a04d0a6f3c29156691 /src/script/squirrel.cpp | |
parent | e63ca12ab815e0cd4d5cc7fd129cde04f7c4404a (diff) | |
download | openttd-962c1a3242e213a65078ed4217112978ddb0c613.tar.xz |
(svn r26776) -Codechange: use safe string functions in script/squirrel*.cpp
Diffstat (limited to 'src/script/squirrel.cpp')
-rw-r--r-- | src/script/squirrel.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index bfffc5c3d..22e5354b6 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -19,14 +19,7 @@ #include <../squirrel/sqpcheader.h> #include <../squirrel/sqvm.h> -/* Due to the different characters for Squirrel, the scsnprintf might be a simple - * snprint which triggers the safeguard. But it isn't always a simple snprintf. - * Likewise for scvsnprintf and scstrcat. - * TODO: use properly safe functions now that Squirrel uses chars exclusively. */ #include "../safeguards.h" -#undef snprintf -#undef vsnprintf -#undef strcat void Squirrel::CompileError(HSQUIRRELVM vm, const SQChar *desc, const SQChar *source, SQInteger line, SQInteger column) { @@ -51,7 +44,7 @@ void Squirrel::ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) SQChar buf[1024]; va_start(arglist, s); - vsnprintf(buf, lengthof(buf), s, arglist); + vseprintf(buf, lastof(buf), s, arglist); va_end(arglist); /* Check if we have a custom print function */ @@ -107,9 +100,9 @@ void Squirrel::PrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) SQChar buf[1024]; va_start(arglist, s); - vsnprintf(buf, lengthof(buf) - 2, s, arglist); + vseprintf(buf, lastof(buf) - 2, s, arglist); va_end(arglist); - strcat(buf, "\n"); + strecat(buf, "\n", lastof(buf)); /* Check if we have a custom print function */ SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func; |