Send 'NULL' string if there is no private data 52/279052/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 1 Aug 2022 07:13:48 +0000 (16:13 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Mon, 1 Aug 2022 07:18:11 +0000 (16:18 +0900)
- Issue:
When server sends null pointer through TIDL parameter, client may
receive unhanlded error.

- Solution:
This is because null pointer can occur invalid access on TIDL logic. To
prevent this situation, this patch sends 'NULL' string instead of null
pointer. Through this change, client always can access valid memory
pointer.

Change-Id: I2685ca0a836c360b3a784da804bbabfabb7df783
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/ttsd_server.c
server/ttsd_tidl.c

index 14fcb287a005e1587e3cd59760a3e448a9d1a441..6b01702dda8e0b57a7d5f57fc69114ea27785850 100644 (file)
@@ -1146,13 +1146,19 @@ int ttsd_server_get_private_data(unsigned int uid, const char* key, char** data)
                return TTSD_ERROR_INVALID_STATE;
        }
 
-       int ret = ttsd_engine_get_private_data(key, data);
+       char* temp_data = NULL;
+       int ret = ttsd_engine_get_private_data(key, &temp_data);
        if (0 != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get private data : ret(%d)", ret);
        } else {
                SLOG(LOG_DEBUG, tts_tag(), "[Server] Get private data, key(%s), data(%s)", key, *data);
        }
 
+       if (NULL == temp_data) {
+               temp_data = strdup("NULL");
+       }
+       *data = temp_data;
+
        return ret;
 }
 
index f5cdca824704d2c8ab505efbfcb0d53f69bebd75..fe0cf2a97562574bc12da1f0bbc13e55f44370d0 100644 (file)
@@ -421,16 +421,12 @@ static int __get_private_cb(rpc_port_stub_tts_context_h context, int uid, const
        unsigned int u_uid = (unsigned int)uid;
        SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET PRIVATE DATA (%u)", u_uid);
 
-       char *tmp = NULL;
-       int ret = ttsd_server_get_private_data(u_uid, key, &tmp);
+       int ret = ttsd_server_get_private_data(u_uid, key, data);
        if (TTSD_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS GET PRIVATE DATA (%u) fail (%d/%s) <<<<<", u_uid, ret, get_error_message(ret));
-               free(tmp);
                return ret;
        }
 
-       *data = tmp;
-
        SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
        return TTSD_ERROR_NONE;
 }