Blame src/regression/sscanf-eof.c
|
Szabolcs Nagy |
281b80 |
// introduced by d6c855caa88ddb1ab6e24e23a14b1e7baf4ba9c7 2018-09-15
|
|
Szabolcs Nagy |
281b80 |
// sscanf may crash on short input
|
|
Szabolcs Nagy |
281b80 |
#include <stdio.h>
|
|
Szabolcs Nagy |
281b80 |
#include "test.h"
|
|
Szabolcs Nagy |
281b80 |
|
|
Szabolcs Nagy |
281b80 |
int main(void)
|
|
Szabolcs Nagy |
281b80 |
{
|
|
Szabolcs Nagy |
281b80 |
const char *s = "0";
|
|
Szabolcs Nagy |
281b80 |
const char *fmt = "%f%c";
|
|
Szabolcs Nagy |
281b80 |
float f = 1.0f;
|
|
Szabolcs Nagy |
281b80 |
char c = 'x';
|
|
Szabolcs Nagy |
281b80 |
int r = sscanf(s, fmt, &f, &c);
|
|
Szabolcs Nagy |
281b80 |
if (r != 1)
|
|
Szabolcs Nagy |
281b80 |
t_error("sscanf(\"%s\", \"%s\",..) returned %d, wanted 1\n", s, fmt, r);
|
|
Szabolcs Nagy |
281b80 |
if (f != 0.0f || c != 'x')
|
|
Szabolcs Nagy |
281b80 |
t_error("sscanf(\"%s\", \"%s\",..) assigned f=%f c='%c', wanted i=0 c='x'\n", s, fmt, f, c);
|
|
Szabolcs Nagy |
281b80 |
return t_status;
|
|
Szabolcs Nagy |
281b80 |
}
|