projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d3f1743
)
Translations: prevent remote crash with invalid translations
author
Ekdohibs
<nathanael.courant@laposte.net>
Fri, 25 Aug 2017 11:06:59 +0000
(13:06 +0200)
committer
Ekdohibs
<nathanael.courant@laposte.net>
Fri, 25 Aug 2017 11:06:59 +0000
(13:06 +0200)
src/util/string.cpp
patch
|
blob
|
history
diff --git
a/src/util/string.cpp
b/src/util/string.cpp
index 6335aeafe4ae57bbdc2112a3f2ac385eef54c01d..bb2d2f6a7b9531cb6ad4a00b9c0e7bc671733785 100644
(file)
--- 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();
}