]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_ssml] replace strncpy() with snprintf() to fix errors reported by newer compilers.
authorChris Rienzo <chris@signalwire.com>
Tue, 11 May 2021 20:42:23 +0000 (16:42 -0400)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:00:47 +0000 (22:00 +0300)
src/mod/formats/mod_ssml/mod_ssml.c

index 633b08dd076a4c2d501b19a720648a57d0365ab3..90df8ba8c2a0af7d70db11c4084d99564776adad 100644 (file)
@@ -472,8 +472,7 @@ static int process_xml_lang(struct ssml_parser *parsed_data, char **atts)
                while (atts[i]) {
                        if (!strcmp("xml:lang", atts[i])) {
                                if (!zstr(atts[i + 1])) {
-                                       strncpy(cur_node->language, atts[i + 1], LANGUAGE_LEN);
-                                       cur_node->language[LANGUAGE_LEN - 1] = '\0';
+                                       snprintf(cur_node->language, LANGUAGE_LEN, "%s", atts[i + 1]);
                                }
                        }
                        i += 2;
@@ -494,18 +493,15 @@ static int process_voice(struct ssml_parser *parsed_data, char **atts)
                while (atts[i]) {
                        if (!strcmp("xml:lang", atts[i])) {
                                if (!zstr(atts[i + 1])) {
-                                       strncpy(cur_node->language, atts[i + 1], LANGUAGE_LEN);
-                                       cur_node->language[LANGUAGE_LEN - 1] = '\0';
+                                       snprintf(cur_node->language, LANGUAGE_LEN, "%s", atts[i + 1]);
                                }
                        } else if (!strcmp("name", atts[i])) {
                                if (!zstr(atts[i + 1])) {
-                                       strncpy(cur_node->name, atts[i + 1], NAME_LEN);
-                                       cur_node->name[NAME_LEN - 1] = '\0';
+                                       snprintf(cur_node->name, NAME_LEN, "%s", atts[i + 1]);
                                }
                        } else if (!strcmp("gender", atts[i])) {
                                if (!zstr(atts[i + 1])) {
-                                       strncpy(cur_node->gender, atts[i + 1], GENDER_LEN);
-                                       cur_node->gender[GENDER_LEN - 1] = '\0';
+                                       snprintf(cur_node->gender, GENDER_LEN, "%s", atts[i + 1]);
                                }
                        }
                        i += 2;
@@ -633,8 +629,7 @@ static int tag_hook(void *user_data, char *name, char **atts, int type)
                }
                new_node->tts_voice = NULL;
                new_node->say_macro = NULL;
-               strncpy(new_node->tag_name, name, TAG_LEN);
-               new_node->tag_name[TAG_LEN - 1] = '\0';
+               snprintf(new_node->tag_name, TAG_LEN, "%s", name);
                parsed_data->cur_node = new_node;
                result = process_tag(parsed_data, name, atts);
        }
@@ -743,8 +738,7 @@ static int process_cdata_tts(struct ssml_parser *parsed_data, char *data, size_t
                /* try macro */
                to_say = malloc(len + 1);
                switch_assert(to_say);
-               strncpy(to_say, data, len);
-               to_say[len] = '\0';
+               snprintf(to_say, len + 1, "%s", data);
                if (!cur_node->say_macro || !get_file_from_macro(parsed_data, to_say)) {
                        /* use voice instead */
                        if (!get_file_from_voice(parsed_data, to_say)) {