Blame src/regression/setvbuf-unget.c
|
Szabolcs Nagy |
12e1df |
// commit: 9cad27a3dc1a4eb349b6591e4dc8cc89dce32277
|
|
Szabolcs Nagy |
12e1df |
// ungetc after setvbuf should not clobber memory below buffer
|
|
Szabolcs Nagy |
12e1df |
#include <stdio.h>
|
|
Szabolcs Nagy |
12e1df |
#include <string.h>
|
|
Szabolcs Nagy |
12e1df |
#include "test.h"
|
|
Szabolcs Nagy |
12e1df |
|
|
Szabolcs Nagy |
12e1df |
int main(void)
|
|
Szabolcs Nagy |
12e1df |
{
|
|
Szabolcs Nagy |
12e1df |
char buf[1024] = "hello world";
|
|
Szabolcs Nagy |
12e1df |
setvbuf(stdin, buf+12, _IOFBF, sizeof buf - 12);
|
|
Szabolcs Nagy |
12e1df |
while (ungetc('x', stdin)!=EOF);
|
|
Szabolcs Nagy |
12e1df |
if (strcmp(buf, "hello world"))
|
|
Szabolcs Nagy |
12e1df |
t_error("ungetc clobbered outside buffer: [%.12s]\n", buf);
|
|
Szabolcs Nagy |
12e1df |
return t_status;
|
|
Szabolcs Nagy |
12e1df |
}
|