summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-11 17:35:24 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-11 18:00:22 +0300
commit52c7195a8ee91f95ef134d9798a47ea313df16c8 (patch)
treeca1f32cfadce611a1820b50f5386c02cd2ce06ae /src/utils
parentf1b82c1b06604c2c1eed750a6c980aa0b5355560 (diff)
downloadmanaverse-52c7195a8ee91f95ef134d9798a47ea313df16c8.tar.gz
manaverse-52c7195a8ee91f95ef134d9798a47ea313df16c8.tar.bz2
manaverse-52c7195a8ee91f95ef134d9798a47ea313df16c8.tar.xz
manaverse-52c7195a8ee91f95ef134d9798a47ea313df16c8.zip
Second part of checks from Parasoft C++ Test.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/langs.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 6e0390494..7c514ac9c 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -24,18 +24,29 @@
#include "debug.h"
+static char *getLangName()
+{
+ const char *const lang = getenv("LANG");
+ if (lang && strlen(lang) > 1000)
+ return nullptr;
+ return lang;
+}
+
LangVect getLang()
{
LangVect langs;
-
std::string lang = config.getStringValue("lang").c_str();
if (lang.empty())
{
- const char *const lng = getenv("LANG");
+ const char *const lng = getLangName();
if (!lng)
return langs;
lang = lng;
}
+ else if (lang.size() > 1000)
+ {
+ return langs;
+ }
size_t dot = lang.find(".");
if (dot != std::string::npos)
@@ -52,11 +63,15 @@ std::string getLangSimple()
const std::string lang = config.getStringValue("lang").c_str();
if (lang.empty())
{
- const char *const lng = getenv("LANG");
+ const char *const lng = getLangName();
if (!lng)
return "";
return lng;
}
+ else if (lang.size() > 1000)
+ {
+ return "";
+ }
return lang;
}
@@ -65,11 +80,15 @@ std::string getLangShort()
std::string lang = config.getStringValue("lang").c_str();
if (lang.empty())
{
- const char *const lng = getenv("LANG");
+ const char *const lng = getLangName();
if (!lng)
return "";
lang = lng;
}
+ else if (lang.size() > 1000)
+ {
+ return "";
+ }
size_t dot = lang.find(".");
if (dot != std::string::npos)