1570af302Sopenharmony_ci// introduced by d6c855caa88ddb1ab6e24e23a14b1e7baf4ba9c7 2018-09-15
2570af302Sopenharmony_ci// sscanf may crash on short input
3570af302Sopenharmony_ci#include <stdio.h>
4570af302Sopenharmony_ci#include "test.h"
5570af302Sopenharmony_ci
6570af302Sopenharmony_ciint main(void)
7570af302Sopenharmony_ci{
8570af302Sopenharmony_ci	const char *s = "0";
9570af302Sopenharmony_ci	const char *fmt = "%f%c";
10570af302Sopenharmony_ci	float f = 1.0f;
11570af302Sopenharmony_ci	char c = 'x';
12570af302Sopenharmony_ci	int r = sscanf(s, fmt, &f, &c);
13570af302Sopenharmony_ci	if (r != 1)
14570af302Sopenharmony_ci		t_error("sscanf(\"%s\", \"%s\",..) returned %d, wanted 1\n", s, fmt, r);
15570af302Sopenharmony_ci	if (f != 0.0f || c != 'x')
16570af302Sopenharmony_ci		t_error("sscanf(\"%s\", \"%s\",..) assigned f=%f c='%c', wanted i=0 c='x'\n", s, fmt, f, c);
17570af302Sopenharmony_ci	return t_status;
18570af302Sopenharmony_ci}
19