Get strncpy length right for TLD lookup string

git-svn-id: https://cld2.googlecode.com/svn/trunk@73 b252ecd4-b096-bf77-eb8e-91563289f87e
This commit is contained in:
dsites@google.com
2013-08-25 17:14:22 +00:00
parent dfbaac9bcc
commit 956e8de541

View File

@@ -1447,7 +1447,7 @@ void SetCLDTLDHint(const char* tld, CLDLangPriors* langpriors) {
int len = strlen(tld); int len = strlen(tld);
if (len > 3) {return;} // Ignore if more than three letters if (len > 3) {return;} // Ignore if more than three letters
char local_tld[4]; char local_tld[4];
strncpy(local_tld, tld, len); strncpy(local_tld, tld, 4);
local_tld[3] = '\0'; // Safety move local_tld[3] = '\0'; // Safety move
// Lowercase // Lowercase
for (int i = 0; i < len; ++i) {local_tld[i] |= 0x20;} for (int i = 0; i < len; ++i) {local_tld[i] |= 0x20;}