#ifdef USE_BUILTINS
# define BUILTIN(f) __builtin_ ## f
#else
# define BUILTIN(f) f
#endif
#include "Inputs/system-header-simulator-for-valist.h"
#include "Inputs/system-header-simulator-for-simple-stream.h"
typedef typeof(sizeof(int)) size_t;
void test_float_condition(void) {
for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} for (float x = 100000001.0f; x <= 100000010.0f; x += 1.0f) {} for (float x = 100000001.0f; x <= 100000010.0f; x++ ) {} for (double x = 100000001.0; x <= 100000010.0; x++ ) {} for (double x = 100000001.0; ((x)) <= 100000010.0; ((x))++ ) {}
for (double x = 100000001.0; 100000010.0 >= x; x = x + 1.0 ) {}
int i = 0;
for (double x = 100000001.0; ((x)) <= 100000010.0; ((x))++, ++i ) {}
typedef float FooType;
for (FooType x = 100000001.0f; x <= 100000010.0f; x++ ) {} }
int bcmp(const void *, const void *, size_t);
int test_bcmp(void *a, void *b, size_t n) {
return bcmp(a, b, n); }
void bcopy(void *, void *, size_t);
void test_bcopy(void *a, void *b, size_t n) {
bcopy(a, b, n); }
void bzero(void *, size_t);
void test_bzero(void *a, size_t n) {
bzero(a, n); }
char* gets(char *buf);
void test_gets(void) {
char buff[1024];
gets(buff); }
int getpw(unsigned int uid, char *buf);
void test_getpw(void) {
char buff[1024];
getpw(2, buff); }
typedef unsigned int __uint32_t;
typedef __uint32_t __darwin_uid_t;
typedef __uint32_t __darwin_gid_t;
typedef __darwin_uid_t uid_t;
typedef __darwin_gid_t gid_t;
int setuid(uid_t);
int setregid(gid_t, gid_t);
int setreuid(uid_t, uid_t);
extern void check(int);
void abort(void);
void test_setuid(void)
{
setuid(2); setuid(0); if (setuid (2) != 0)
abort();
int t = setuid(2); (void)setuid (2);
check(setuid (2));
setreuid(2,2); setregid(2,2); }
typedef unsigned short *ushort_ptr_t; int rand(void);
double drand48(void);
double erand48(unsigned short[3]);
long jrand48(ushort_ptr_t);
void lcong48(unsigned short[7]);
long lrand48(void);
long mrand48(void);
long nrand48(unsigned short[3]);
long random(void);
int rand_r(unsigned *);
void test_rand(void)
{
unsigned short a[7];
unsigned b;
rand(); drand48(); erand48(a); jrand48(a); lcong48(a); lrand48(); mrand48(); nrand48(a); rand_r(&b); random(); }
char *mktemp(char *buf);
void test_mktemp(void) {
char *x = mktemp("/tmp/zxcv"); }
#ifdef VARIANT
#define __strcpy_chk BUILTIN(__strcpy_chk)
char *__strcpy_chk(char *restrict s1, const char *restrict s2, size_t destlen);
#define strcpy(a,b) __strcpy_chk(a,b,(size_t)-1)
#else
#define strcpy BUILTIN(strcpy)
char *strcpy(char *restrict s1, const char *restrict s2);
#endif
void test_strcpy(void) {
char x[4];
char *y;
strcpy(x, y); }
void test_strcpy_2(void) {
char x[4];
strcpy(x, "abcd"); }
void test_strcpy_safe(void) {
char x[5];
strcpy(x, "abcd");
}
void test_strcpy_safe_2(void) {
struct {char s1[100];} s;
strcpy(s.s1, "hello");
}
#ifdef VARIANT
#define __strcat_chk BUILTIN(__strcat_chk)
char *__strcat_chk(char *restrict s1, const char *restrict s2, size_t destlen);
#define strcat(a,b) __strcat_chk(a,b,(size_t)-1)
#else
#define strcat BUILTIN(strcat)
char *strcat(char *restrict s1, const char *restrict s2);
#endif
void test_strcat(void) {
char x[4];
char *y;
strcat(x, y); }
typedef int __int32_t;
typedef __int32_t pid_t;
pid_t vfork(void);
void test_vfork(void) {
vfork(); }
char *mkdtemp(char *template);
int mkstemps(char *template, int suffixlen);
int mkstemp(char *template);
char *mktemp(char *template);
void test_mkstemp(void) {
mkstemp("XX"); mkstemp("XXXXXX");
mkstemp("XXXXXXX");
mkstemps("XXXXXX", 0);
mkstemps("XXXXXX", 1); mkstemps("XXXXXX", 2); mkdtemp("XX"); mkstemp("X"); mkdtemp("XXXXXX");
}
typedef int wchar_t;
int sprintf(char *str, const char *format, ...);
int scanf(const char *format, ...);
int wscanf(const wchar_t *format, ...);
int fscanf(FILE *stream, const char *format, ...);
int fwscanf(FILE *stream, const wchar_t *format, ...);
int vscanf(const char *format, va_list arg);
int vwscanf(const wchar_t *format, va_list arg);
int vfscanf(FILE *stream, const char *format, va_list arg);
int vfwscanf(FILE *stream, const wchar_t *format, va_list arg);
int sscanf(const char *s, const char *format, ...);
int swscanf(const wchar_t *ws, const wchar_t *format, ...);
int vsscanf(const char *s, const char *format, va_list arg);
int vswscanf(const wchar_t *ws, const wchar_t *format, va_list arg);
int swprintf(wchar_t *ws, size_t len, const wchar_t *format, ...);
int snprintf(char *s, size_t n, const char *format, ...);
int vswprintf(wchar_t *ws, size_t len, const wchar_t *format, va_list arg);
int vsnprintf(char *s, size_t n, const char *format, va_list arg);
void *memcpy(void *destination, const void *source, size_t num);
void *memmove(void *destination, const void *source, size_t num);
char *strncpy(char *destination, const char *source, size_t num);
char *strncat(char *destination, const char *source, size_t num);
void *memset(void *ptr, int value, size_t num);
void test_deprecated_or_unsafe_buffer_handling_1(void) {
char buf [5];
wchar_t wbuf [5];
int a;
FILE *file;
sprintf(buf, "a"); scanf("%d", &a); scanf("%s", buf); scanf("%4s", buf); wscanf((const wchar_t*) L"%s", buf); fscanf(file, "%d", &a); fscanf(file, "%s", buf); fscanf(file, "%4s", buf); fwscanf(file, (const wchar_t*) L"%s", wbuf); sscanf("5", "%d", &a); sscanf("5", "%s", buf); sscanf("5", "%4s", buf); swscanf(L"5", (const wchar_t*) L"%s", wbuf); swprintf(L"5", 1, (const wchar_t*) L"%s", wbuf); snprintf("5", 1, "%s", buf); memcpy(buf, wbuf, 1); memmove(buf, wbuf, 1); strncpy(buf, "a", 1); strncat(buf, "a", 1); memset(buf, 'a', 1); }
void test_deprecated_or_unsafe_buffer_handling_2(const char *format, ...) {
char buf [5];
FILE *file;
va_list args;
va_start(args, format);
vsprintf(buf, format, args); vscanf(format, args); vfscanf(file, format, args); vsscanf("a", format, args); vsnprintf("a", 1, format, args); }
void test_deprecated_or_unsafe_buffer_handling_3(const wchar_t *format, ...) {
wchar_t wbuf [5];
FILE *file;
va_list args;
va_start(args, format);
vwscanf(format, args); vfwscanf(file, format, args); vswscanf(L"a", format, args); vswprintf(L"a", 1, format, args); }