Skip to content

Commit

Permalink
libc: fix setvbuf_fullbuffer_overflow testcase
Browse files Browse the repository at this point in the history
The test case checks fully buffered mode.
Previous implementation required data overflowing the buffer
(sending 10 bytes when a buffer is 8 bytes long) to be written to a file at once
which is not required by POSIX.
The current solution forces flushing the remaining 2 bytes anyway.

JIRA: CI-507
  • Loading branch information
damianloew committed Oct 14, 2024
1 parent 0733d9f commit 036b90f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc/stdio/stdio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,10 @@ TEST(stdio_bufs, setvbuf_fullbuffer_overflow)
TEST_ASSERT_EQUAL_INT(0, setvbuf(filep, buf2, _IOFBF, sizeof(buf2)));

TEST_ASSERT_GREATER_THAN_INT(0, fputs(data, filep));
/* Flush is used, because it's possible that overflow data will be written anyway (glibc) */
fflush(filep);
TEST_ASSERT_NOT_NULL(fgets(buf, sizeof(buf), filep2));
TEST_ASSERT_EQUAL_STRING(data, buf);
TEST_ASSERT_EQUAL_INT(strlen(data), strlen(buf));
}

Expand Down

0 comments on commit 036b90f

Please sign in to comment.