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

index f66aa25..5dc3658 100644 (file)
@@ -591,7 +591,7 @@ 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 if (n < 1024) {
+       } else if (n - 1 > 0 && n < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);
index aec6ebf..df25e4c 100644 (file)
@@ -636,7 +636,7 @@ 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 if (n < 1024) {
+       } else if (n - 1 > 0 && n < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);
index 4dc5ab1..1f911ae 100644 (file)
@@ -1042,7 +1042,7 @@ 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 if (n < 1024) {
+       } else if (n - 1 > 0 && n < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);