espeak-ng/Copy-name-in-LoadDictionary-if-not-dictionary_name.patch
2021-06-17 16:54:23 +08:00

31 lines
1.2 KiB
Diff

From b60d2452c34ac6ebf01a3c09c17193b8c8e2a3fd Mon Sep 17 00:00:00 2001
From: "Reece H. Dunn" <msclrhd@gmail.com>
Date: Wed, 21 Mar 2018 20:37:44 +0000
Subject: [PATCH] Copy name in LoadDictionary if not dictionary_name
compiledict.c sets dict_name to dictionary_name if dict_name is
not set, and passes that to LoadDictionary. LoadDictionary then
copies the passed in name to dictionary_name.
This causes -fsanitize=address to fail with overlapping memory
addresses passed to strncpy (copying the string to itself). As
such, don't copy the name in this case.
---
src/libespeak-ng/dictionary.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c
index f6bdf1823..5d1f44ba0 100644
--- a/src/libespeak-ng/dictionary.c
+++ b/src/libespeak-ng/dictionary.c
@@ -201,7 +201,8 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
int size;
char fname[sizeof(path_home)+20];
- strncpy(dictionary_name, name, 40); // currently loaded dictionary name
+ if (dictionary_name != name)
+ strncpy(dictionary_name, name, 40); // currently loaded dictionary name
strncpy(tr->dictionary_name, name, 40);
// Load a pronunciation data file into memory