Fix overflow
authorCheoleun Moon <chleun.moon@samsung.com>
Thu, 2 Apr 2020 03:12:15 +0000 (12:12 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Thu, 2 Apr 2020 03:12:15 +0000 (12:12 +0900)
test/wifi-aware-publish-test.c
test/wifi-aware-subscribe-test.c
test/wifi-aware-test.c

index 39e34f1..b452583 100644 (file)
@@ -591,10 +591,12 @@ static gboolean __test_terminal_read_std_input(GIOChannel * source,
                printf("Error: read() from stdin returns 0.\n");
        } else if (n < 0) {
                printf("input: read, err\n");
-       } else {
+       } else if (n < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);
+       } else {
+               printf("invalid input\n");
        }
 
        return TRUE;
index 2331522..1937313 100644 (file)
@@ -636,10 +636,12 @@ static gboolean __test_terminal_read_std_input(GIOChannel * source,
                printf("Error: read() from stdin returns 0.\n");
        } else if (n < 0) {
                printf("input: read, err\n");
-       } else {
+       } else if (n < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);
+       } else {
+               printf("invalid input\n");
        }
 
        return TRUE;
index 2fbfc44..f5e87b6 100644 (file)
@@ -1042,10 +1042,12 @@ static gboolean __test_terminal_read_std_input(GIOChannel * source,
                printf("Error: read() from stdin returns 0.\n");
        } else if (n < 0) {
                printf("input: read, err\n");
-       } else {
+       } else if (n < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);
+       } else {
+               printf("invalid input\n");
        }
 
        return TRUE;