mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-04 22:38:33 +00:00
Use strcpy instead of memcpy+strlen.
This replaces uses of: memcpy(dst, src, strlen(src)) with: strcpy(dst, src) This fixes issues with reading past the end of the copied buffer (e.g. when processing word-based replacements for emoji characters) by ensuring that the destination buffer is null terminated. Reported by Michael Curran <mick@nvaccess.org>
This commit is contained in:
@@ -2394,7 +2394,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
match1.end_type |= p - p_start;
|
||||
}
|
||||
strcpy(end_phonemes, match1.phonemes);
|
||||
memcpy(p_start, word_copy, strlen(word_copy));
|
||||
strcpy(p_start, word_copy);
|
||||
return match1.end_type;
|
||||
}
|
||||
}
|
||||
@@ -2404,7 +2404,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(p_start, word_copy, strlen(word_copy));
|
||||
strcpy(p_start, word_copy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -795,7 +795,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char
|
||||
if (end2) {
|
||||
RemoveEnding(tr, wordx, end2, word_copy);
|
||||
end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags|FLAG_NO_TRACE, dictionary_flags);
|
||||
memcpy(wordx, word_copy, strlen(word_copy));
|
||||
strcpy(wordx, word_copy);
|
||||
if ((end_type & SUFX_P) == 0) {
|
||||
// after removing the suffix, the prefix is no longer recognised.
|
||||
// Keep the suffix, but don't use the prefix
|
||||
@@ -902,7 +902,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char
|
||||
wordx[-1] = ' ';
|
||||
if (phonemes[0] == phonSWITCH) {
|
||||
// change to another language in order to translate this word
|
||||
memcpy(wordx, word_copy, strlen(word_copy));
|
||||
strcpy(wordx, word_copy);
|
||||
strcpy(word_phonemes, phonemes);
|
||||
return 0;
|
||||
}
|
||||
@@ -920,7 +920,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char
|
||||
found = LookupDictList(tr, &wordx, phonemes, dictionary_flags2, end_flags, wtab); // without prefix and suffix
|
||||
if (phonemes[0] == phonSWITCH) {
|
||||
// change to another language in order to translate this word
|
||||
memcpy(wordx, word_copy, strlen(word_copy));
|
||||
strcpy(wordx, word_copy);
|
||||
strcpy(word_phonemes, phonemes);
|
||||
return 0;
|
||||
}
|
||||
@@ -960,7 +960,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char
|
||||
if (phonemes[0] == phonSWITCH) {
|
||||
// change to another language in order to translate this word
|
||||
strcpy(word_phonemes, phonemes);
|
||||
memcpy(wordx, word_copy, strlen(word_copy));
|
||||
strcpy(wordx, word_copy);
|
||||
wordx[-1] = c_temp;
|
||||
return 0;
|
||||
}
|
||||
@@ -974,7 +974,7 @@ static int TranslateWord3(Translator *tr, char *word_start, WORD_TAB *wtab, char
|
||||
AppendPhonemes(tr, phonemes, N_WORD_PHONEMES, end_phonemes);
|
||||
end_phonemes[0] = 0;
|
||||
}
|
||||
memcpy(wordx, word_copy, strlen(word_copy));
|
||||
strcpy(wordx, word_copy);
|
||||
}
|
||||
|
||||
wordx[-1] = c_temp;
|
||||
@@ -1139,7 +1139,7 @@ int TranslateWord(Translator *tr, char *word_start, WORD_TAB *wtab, char *word_o
|
||||
char word[N_WORD_BYTES+1];
|
||||
word[0] = 0;
|
||||
word[1] = ' ';
|
||||
memcpy(word+2, word_out, strlen(word_out));
|
||||
strcpy(word+2, word_out);
|
||||
word_out = word+2;
|
||||
|
||||
while (*word_out && available > 1) {
|
||||
|
||||
Reference in New Issue
Block a user