From 12e1dfcdbb2de87a28914d7e9a82b5f71b5890d8 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 15 Jul 2018 21:20:21 +0000 Subject: [PATCH] add ungetc with setvbuf test --- src/regression/setvbuf-unget.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/regression/setvbuf-unget.c diff --git a/src/regression/setvbuf-unget.c b/src/regression/setvbuf-unget.c new file mode 100644 index 0000000..8667675 --- /dev/null +++ b/src/regression/setvbuf-unget.c @@ -0,0 +1,15 @@ +// commit: 9cad27a3dc1a4eb349b6591e4dc8cc89dce32277 +// ungetc after setvbuf should not clobber memory below buffer +#include +#include +#include "test.h" + +int main(void) +{ + char buf[1024] = "hello world"; + setvbuf(stdin, buf+12, _IOFBF, sizeof buf - 12); + while (ungetc('x', stdin)!=EOF); + if (strcmp(buf, "hello world")) + t_error("ungetc clobbered outside buffer: [%.12s]\n", buf); + return t_status; +} -- 2.11.4.GIT