diff options
author | Ekdohibs <nathanael.courant@laposte.net> | 2017-08-25 13:06:59 +0200 |
---|---|---|
committer | Ekdohibs <nathanael.courant@laposte.net> | 2017-08-25 13:06:59 +0200 |
commit | 6761e213836e902359c5d0acff277623dc3e1588 (patch) | |
tree | c8c838697c16622da6493579a385a2d3dd4fbb84 | |
parent | d3f1743fdd56da4e3c01739d09ccf02b0466c388 (diff) | |
download | minetest-6761e213836e902359c5d0acff277623dc3e1588.tar.gz minetest-6761e213836e902359c5d0acff277623dc3e1588.tar.bz2 minetest-6761e213836e902359c5d0acff277623dc3e1588.zip |
Translations: prevent remote crash with invalid translations
-rw-r--r-- | src/util/string.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp index 6335aeafe..bb2d2f6a7 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -866,7 +866,12 @@ void translate_string(const std::wstring &s, const std::wstring &textdomain, // Here we have an argument; get its index and add the translated argument to the output. int arg_index = toutput[j] - L'1'; ++j; - result << args[arg_index]; + if (0 <= arg_index && (size_t)arg_index < args.size()) { + result << args[arg_index]; + } else { + // This is not allowed: show an error message + errorstream << "Ignoring out-of-bounds argument escape sequence in translation" << std::endl; + } } res = result.str(); } |