Fix Svace issues 47/60947/1 accepted/tizen/common/20160304.195437 accepted/tizen/ivi/20160305.093155 accepted/tizen/mobile/20160305.093108 accepted/tizen/tv/20160305.093124 accepted/tizen/wearable/20160305.093138 submit/tizen/20160304.045143
authorJiwan Kim <ji-wan.kim@samsung.com>
Thu, 3 Mar 2016 05:57:22 +0000 (14:57 +0900)
committerJiwan Kim <ji-wan.kim@samsung.com>
Thu, 3 Mar 2016 05:57:22 +0000 (14:57 +0900)
Change-Id: I1f2229ed6ab7d2e39b8b253df470d539f55d4dbd

packaging/libtapi.spec
test_src/main.c
test_src/sim.c
test_src/sms.c

index e41f3b1..e220952 100644 (file)
@@ -1,6 +1,6 @@
 %define major 0
-%define minor 7
-%define patchlevel 99
+%define minor 8
+%define patchlevel 0
 
 Name:           libtapi
 Version:        %{major}.%{minor}.%{patchlevel}
index 56a75fe..7151153 100644 (file)
@@ -82,6 +82,10 @@ static int init(MManager *mm, struct menu_data *menu)
                msg("already handle exist");
                return 0;
        }
+       if (subs_type < 1 || subs_type > cp_count) {
+               msg("CP is not exist");
+               return 0;
+       }
        if (cp_list[subs_type-1]) {
                msg("call tel_init(%s)", cp_list[subs_type-1]);
                handle = tel_init(cp_list[subs_type-1]);
index a2e8e72..d240284 100644 (file)
@@ -548,8 +548,8 @@ static int run_sim_set_cf(MManager *mm, struct menu_data *menu)
                cf.cf_data_u.cf.cfu_status = data_sim_set_cf_cfu_status[0] - '0';
                cf.cf_data_u.cf.ton = data_sim_set_cf_ton[0] - '0';
                cf.cf_data_u.cf.npi = data_sim_set_cf_npi[0] - '0';
-               memcpy(&cf.cf_data_u.cf.cfu_num, data_sim_set_cf_number,
-                               sizeof(cf.cf_data_u.cf.cfu_num));
+               snprintf(cf.cf_data_u.cf.cfu_num, TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1,
+                               "%s", data_sim_set_cf_number);
                cf.cf_data_u.cf.cc2_id = data_sim_set_cf_cc2_id[0] - '0';
                cf.cf_data_u.cf.ext7_id = data_sim_set_cf_ext7_id[0] - '0';
        }
@@ -726,7 +726,8 @@ static int run_sim_set_mb(MManager *mm, struct menu_data *menu)
                        TAPI_SIM_XDN_ALPHA_ID_MAX_LEN);
        mb.ton = data_sim_set_mb_ton[0] - '0';
        mb.npi = data_sim_set_mb_npi[0] - '0';
-       memcpy(&mb.num, data_sim_set_mb_number, sizeof(mb.num));
+       snprintf(mb.num, TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1,
+                       "%s", data_sim_set_mb_number);
        mb.cc_id = data_sim_set_mb_cc_id[0] - '0';
        mb.ext1_id = data_sim_set_mb_ext1_id[0] - '0';
 
index dfc6a02..7bc5ad6 100644 (file)
@@ -1842,6 +1842,7 @@ static int Setting(MManager *mm, struct menu_data *menu)
        case 1: { /* Set Service Center Number */
                TelSmsAddressInfo_t sca = {0, };
                unsigned char sca_num[TAPI_SIM_SMSP_ADDRESS_LEN + 1];
+               unsigned char buf[TAPI_SIM_SMSP_ADDRESS_LEN + 2];
                unsigned int sca_length = 0;
                unsigned int additional_len = 0;
                unsigned local_index, j;
@@ -1850,11 +1851,17 @@ static int Setting(MManager *mm, struct menu_data *menu)
 
 RETRY:
                msg("Enter the SCA NUMBER:");
-               ret = scanf("%s", sca_num);
+               /* Limits input length - TAPI_SIM_SMSP_ADDRESS_LEN + 1 */
+               ret = scanf("%21s", buf);
+               ret = strlen((const char*)buf);
                if (ret > TAPI_SIM_SMSP_ADDRESS_LEN) {
+                       int c;
                        msg("Entered SCA is INVALID - SCA length cannot be greater than %d", TAPI_SIM_SMSP_ADDRESS_LEN);
+                       /* Flush input buffer */
+                       while ((c = getchar()) != '\n' && c != EOF);
                        goto RETRY;
                }
+               snprintf((char*)sca_num, TAPI_SIM_SMSP_ADDRESS_LEN+1, "%s", buf);
 
                sca.Npi = TAPI_SIM_NPI_ISDN_TEL;
                sca.Ton = TAPI_SIM_TON_UNKNOWN;
@@ -1946,6 +1953,7 @@ RETRY:
        case 5: {
                unsigned int sca_length;
                unsigned char sca_num[TAPI_SIM_SMSP_ADDRESS_LEN + 1];
+               unsigned char buf[TAPI_SIM_SMSP_ADDRESS_LEN + 2];
                const char *name = "AlphaID";
 
                smsParameters.RecordIndex = 0x00;
@@ -1966,9 +1974,16 @@ RETRY:
 
                do {
                        msg("Enter the SCA NUMBER:");
-                       ret = scanf("%s", sca_num);
-                       if (ret > TAPI_SIM_SMSP_ADDRESS_LEN)
+                       /* Limits input length - TAPI_SIM_SMSP_ADDRESS_LEN + 1 */
+                       ret = scanf("%21s", buf);
+                       ret = strlen((const char*)buf);
+                       if (ret > TAPI_SIM_SMSP_ADDRESS_LEN) {
+                               int c;
                                msg("Entered SCA is INVALID - SCA length cannot be greater than %d", TAPI_SIM_SMSP_ADDRESS_LEN);
+                               /* Flush input buffer */
+                               while ((c = getchar()) != '\n' && c != EOF);
+                       } else
+                               snprintf((char*)sca_num, TAPI_SIM_SMSP_ADDRESS_LEN+1, "%s", buf);
                } while (ret > TAPI_SIM_SMSP_ADDRESS_LEN);
 
                sca_length = SmsUtilEncodeSca(&(smsParameters.TpSvcCntrAddr), sca_num);