Fix static overflow
authorCheoleun Moon <chleun.moon@samsung.com>
Thu, 2 Apr 2020 02:35:54 +0000 (11:35 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Thu, 2 Apr 2020 02:35:54 +0000 (11:35 +0900)
test/wifi-aware-test.c

index 2fbfc44..d6c5b7a 100644 (file)
@@ -428,7 +428,7 @@ static int __set_match_filter(unsigned char match_filter[MAX_MATCH_FILTER_LEN +
                if (scanf("%d", &len) < 0)
                        return -1;
                printf("%d match filter value: ", i);
-               if (scanf("%s", filter) < 0)
+               if (scanf("%255s", filter) < 0)
                        return -1;
                if (len != strlen(filter)) {
                        printf("The length of filter value is not %d\n", len);
@@ -939,9 +939,9 @@ void test_open_data_path()
        __print_result(ret, "wifi_aware_data_path_set_security");
 
        if (security_type == 1) {
-               char key[MAX_PSK_LEN] = {0, };
+               char key[MAX_PSK_LEN + 1] = {0, };
                printf("Passphrase: ");
-               ret = scanf("%s", key);
+               ret = scanf("%63s", key);
                if (ret < 0)
                        return;
                ret = wifi_aware_data_path_set_psk(g_ndp, key);
@@ -949,10 +949,10 @@ void test_open_data_path()
        }
 
        if (security_type == 2) {
-               char key[PMK_LEN] = {0, };
+               char key[PMK_LEN + 1] = {0, };
                unsigned char pmk[PMK_LEN] = {0, };
                printf("PMK: ");
-               ret = scanf("%s", key);
+               ret = scanf("%32s", key);
                if (ret < 0)
                        return;
                memcpy(pmk, key, PMK_LEN);