fix overflow
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 2 Apr 2020 09:07:03 +0000 (18:07 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 2 Apr 2020 09:07:03 +0000 (18:07 +0900)
test/wifi-aware-publish-test.c

index 5dc3658ebad84ff5ebe25455a1456d552de57e37..2d31b200868396f0c751fa3ee1a09d9d0c7c5f24 100644 (file)
@@ -587,16 +587,12 @@ static gboolean __test_terminal_read_std_input(GIOChannel * source,
 
        errno = 0;
        n = read(fd, buf, 1024);
-       if (n == 0) {
-               printf("Error: read() from stdin returns 0.\n");
-       } else if (n < 0) {
-               printf("input: read, err\n");
-       } else if (n - 1 > 0 && n < 1024) {
+       if (n - 1 > 0 && n - 1 < 1024) {
                buf[n - 1] = '\0'; /* remove new line... */
                printf("\n\n");
                __process_input(buf, user_data);
        } else {
-               printf("invalid input\n");
+               printf("read error\n");
        }
 
        return TRUE;