Use safe function to avoid security issues 44/299344/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 26 Sep 2023 07:40:25 +0000 (16:40 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 26 Sep 2023 07:40:25 +0000 (16:40 +0900)
Change-Id: I9d62fb45b44eaaf223aba5c6f58ed504ac6e3027
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/ttsd_server.c

index 0efac81..fd97cf3 100644 (file)
@@ -124,42 +124,14 @@ static void write_debugger_information(speak_data_s *speak_data, const char *app
        if (true != ttsd_engine_select_valid_voice(speak_data->lang, speak_data->vctype, &temp_lang, &temp_type)) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select default voice");
        } else {
-               char vcType[10];
-               sprintf(vcType, "%d", temp_type);
+               char value_buffer[2048] = {0, };
+               snprintf(value_buffer, 2048,
+                               "client=%s|type=%d|speed=%d|language=%s|text=%s|error=%d",
+                               appid, temp_type, speak_data->speed, temp_lang, speak_data->text, ret);
 
-               char ttsSpeed[10];
-               sprintf(ttsSpeed, "%d", speak_data->speed);
+               SLOG(LOG_INFO, tts_tag(), "keyVal : %s", value_buffer);
 
-               char errorRet[10];
-               sprintf(errorRet, "%d", ret);
-
-               char keyVal[500] = {0,};
-               strcat(keyVal,"client=");
-               strcat(keyVal,appid);
-               strcat(keyVal,"|");
-
-               strcat(keyVal,"type=");
-               strcat(keyVal,vcType);
-               strcat(keyVal,"|");
-
-               strcat(keyVal,"speed=");
-               strcat(keyVal,ttsSpeed);
-               strcat(keyVal,"|");
-
-               strcat(keyVal,"language=");
-               strcat(keyVal,temp_lang);
-               strcat(keyVal,"|");
-
-               strcat(keyVal,"text=");
-               strcat(keyVal,speak_data->text);
-               strcat(keyVal,"|");
-
-               strcat(keyVal,"error=");
-               strcat(keyVal,errorRet);
-
-               SLOG(LOG_INFO, tts_tag(), "keyVal : %s",keyVal);
-
-               if (0 != vconf_set_str("db/ttsdebugger/tts_info", keyVal)) {
+               if (0 != vconf_set_str("db/ttsdebugger/tts_info", value_buffer)) {
                        SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set vconf key db/ttsdebugger/tts_info");
                }
        }
@@ -188,7 +160,7 @@ static void __synthesis(unsigned int uid)
                return;
        }
 
-       char appid[1024] = {0, };
+       char appid[512] = {0, };
        if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
        }