From: Gilbok Lee Date: Fri, 4 Dec 2015 07:24:31 +0000 (+0900) Subject: Fix svace defect X-Git-Tag: accepted/tizen/mobile/20151207.123258^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=feb88f0179524d15f93e28031627d89333a15b66;p=platform%2Fcore%2Fapi%2Fmediamuxer.git Fix svace defect Change-Id: Ie17288a3c6ba6aea08b58579365d57bc2437a2a4 Signed-off-by: Gilbok Lee --- diff --git a/src/mediamuxer_ini.c b/src/mediamuxer_ini.c index fcebd5a..2e34173 100644 --- a/src/mediamuxer_ini.c +++ b/src/mediamuxer_ini.c @@ -35,9 +35,9 @@ if (str && \ (strlen(str) > 0) && \ (strlen(str) < MEDIAMUXER_INI_MAX_STRLEN)) { \ - strcpy(x_item, str); \ + strncpy(x_item, str, MEDIAMUXER_INI_MAX_STRLEN - 1); \ } else { \ - strcpy(x_item, x_default); \ + strncpy(x_item, x_default, MEDIAMUXER_INI_MAX_STRLEN - 1); \ } \ } while (0) @@ -63,7 +63,7 @@ do { \ char *usr_ptr = NULL; \ char *token = NULL; \ gchar temp_arr[MEDIAMUXER_INI_MAX_STRLEN] = {0}; \ - MMMEDIAMUXER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \ + MEDIAMUXER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \ token = strtok_r(temp_arr, delimiters, &usr_ptr); \ while (token) { \ index = atoi(token); \ @@ -86,7 +86,7 @@ do { \ char *usr_ptr = NULL; \ char *token = NULL; \ gchar temp_arr[MEDIAMUXER_INI_MAX_STRLEN] = {0}; \ - MMMEDIAMUXER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \ + MEDIAMUXER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \ token = strtok_r(temp_arr, delimiters, &usr_ptr); \ while (token) { \ if (index > x_list_max -1) { \ diff --git a/src/port_gst/mediamuxer_port_gst.c b/src/port_gst/mediamuxer_port_gst.c index 3d280c1..651c05d 100644 --- a/src/port_gst/mediamuxer_port_gst.c +++ b/src/port_gst/mediamuxer_port_gst.c @@ -448,8 +448,8 @@ mx_ret_e _gst_create_pipeline(mxgst_handle_t *gst_handle) for (current = gst_handle->track_info.track_head; current; current = current->next) { if (current->track_index%NO_OF_TRACK_TYPES == 0) { /* Video track */ - sprintf(str_appsrc, "video_appsrc%d", current->track_index); - sprintf(str_parser, "video_parser%d", current->track_index); + snprintf(str_appsrc, MAX_STRING_LENGTH - 1, "video_appsrc%d", current->track_index); + snprintf(str_parser, MAX_STRING_LENGTH - 1, "video_parser%d", current->track_index); current->appsrc = gst_element_factory_make("appsrc", str_appsrc); diff --git a/test/mediamuxer_test.c b/test/mediamuxer_test.c index da6440c..f23d01c 100644 --- a/test/mediamuxer_test.c +++ b/test/mediamuxer_test.c @@ -43,6 +43,7 @@ #define DEFAULT_OUT_BUF_WIDTH 640 #define DEFAULT_OUT_BUF_HEIGHT 480 #define OUTBUF_SIZE (DEFAULT_OUT_BUF_WIDTH * DEFAULT_OUT_BUF_HEIGHT * 3 / 2) +#define MAX_INPUT_SIZE 2048 #define DEFAULT_SAMPPLERATE 44100 #define DEFAULT_CHANNEL 2 @@ -84,8 +85,8 @@ static int bitrate = DEFAULT_BITRATE; int iseos_codec = 0; bool validate_with_codec = false; bool validate_multitrack = false; -char file_mp4[2048]; -char data_sink[2048]; +char file_mp4[MAX_INPUT_SIZE]; +char data_sink[MAX_INPUT_SIZE]; bool have_mp4 = false; bool have_vid_track = false; bool have_aud_track = false; @@ -152,10 +153,10 @@ int test_mediamuxer_set_data_sink() int test_mediamuxer_add_track_video() { media_format_mimetype_e mimetype; - int width; - int height; - int avg_bps; - int max_bps; + int width = 0; + int height = 0; + int avg_bps = 0; + int max_bps = 0; g_print("test_mediamuxer_add_track_video\n"); media_format_create(&media_format); @@ -203,10 +204,10 @@ int test_mediamuxer_add_track_video() int test_mediamuxer_add_track_audio() { media_format_mimetype_e mimetype; - int channel; - int samplerate; - int bit; - int avg_bps; + int channel = 0; + int samplerate = 0; + int bit = 0; + int avg_bps = 0; g_print("test_mediamuxer_add_track_audio\n"); media_format_create(&media_format_a); @@ -489,12 +490,12 @@ static void interpret(char *cmd) } case CURRENT_STATUS_MP4_FILENAME: { input_filepath(cmd); - strcpy(file_mp4, cmd); + strncpy(file_mp4, cmd, MAX_INPUT_SIZE - 1); g_menu_state = CURRENT_STATUS_MAINMENU; break; } case CURRENT_STATUS_DATA_SINK: { - strcpy(data_sink, cmd); + strncpy(data_sink, cmd, MAX_INPUT_SIZE - 1); test_mediamuxer_set_data_sink(); g_menu_state = CURRENT_STATUS_MAINMENU; break; diff --git a/test/mediamuxer_test_with_mediacodec.c b/test/mediamuxer_test_with_mediacodec.c index aa6ca03..f14b90d 100644 --- a/test/mediamuxer_test_with_mediacodec.c +++ b/test/mediamuxer_test_with_mediacodec.c @@ -486,7 +486,7 @@ int __mediacodec_process_input(void) if (bMultipleFiles) { if (g_uri[g_len-1] != '/') g_uri[g_len++] = '/'; - sprintf(g_uri+g_len, "%05d", frame_count); + snprintf(g_uri+g_len, MAX_STRING_LEN - g_len, "%05d", frame_count); } fp_src = fopen(g_uri, "r"); if (fp_src == NULL) {