Ejemplo n.º 1
0
int main(int argc, char **argv) {
  int N = SYMBOLIC_SIZE;
  unsigned char *buf = malloc(N);
  int i;
  
  klee_make_symbolic(buf, N);
  if (validate(buf, N))
    return buf[0];
  return 0;
}
Ejemplo n.º 2
0
void *hi(void *ptr)
{
//     int a = *(int *)ptr;			
	int a;
	 klee_make_symbolic(&a, sizeof(a), "input");
	 if(a > 5)
		printf("hell");
	 else
		printf("cry");
}
Ejemplo n.º 3
0
int main() {
    char buf[4];

    klee_make_symbolic(buf, sizeof buf);
    klee_prefer_cex(buf, buf[0]=='H');
    klee_prefer_cex(buf, buf[1]=='i');
    klee_prefer_cex(buf, buf[2]=='\0');

    return 0;
}
Ejemplo n.º 4
0
int main() {
  unsigned int x;
  unsigned int y;
  volatile unsigned int result;

  klee_make_symbolic(&x, sizeof(x), "x");
  klee_make_symbolic(&y, sizeof(y), "y");

  // CHECK: ubsan_unsigned_overflow.c:[[@LINE+1]]: overflow on addition
  result = x + y;

  // CHECK: ubsan_unsigned_overflow.c:[[@LINE+1]]: overflow on subtraction
  result = x - y;

  // CHECK: ubsan_unsigned_overflow.c:[[@LINE+1]]: overflow on multiplication
  result = x * y;

  return 0;
}
Ejemplo n.º 5
0
StringBuffer::StringBuffer(char *str) {
    int length = strlen(str) + 16;
    value = new char[length];
    value_length = length;
    count = 0;
    klee_make_symbolic(&buffcount, sizeof(buffcount), "buffcount"); //Nuno
     buffcount = 0; //Nuno
    pthread_mutex_init(&mutex_lock, NULL);
    append(str);
}
Ejemplo n.º 6
0
/**
 * This test generates one execution state without constraints.
 *
 * The state gets terminated (in this case return) and initial values
 * are generated.
 * Make sure we are able to generate an input.
 */
int main() {
  int d;

  klee_make_symbolic(&d, sizeof(d), "d");

  // CHECK-NOT: unable to compute initial values (invalid constraints?)!
  if ((d & 2) / 4)
    return 1;
  return 0;
}
Ejemplo n.º 7
0
int main(int argc, char** argv) {
  int x = 0;
  klee_make_symbolic(&x, sizeof(x), "x");

  if (x == 0) {
    printf("x is 0\n");
  } else {
    printf("x is not 0\n");
  }
  return 0;
}
Ejemplo n.º 8
0
int main(void)
{
  int a;
  
  klee_make_symbolic(&a, sizeof(int), "a");
  klee_assume(a >= 0);
  klee_assume(a <= 10);

  In = fib(a);
  return 0;
}
Ejemplo n.º 9
0
int main(int argc, char** argv) {
  int x, y, *p = 0;
  
  klee_make_symbolic(&x, sizeof x);
  klee_make_symbolic(&y, sizeof y);

  if (x)
    fprintf(stderr, "x\n");
  else fprintf(stderr, "!x\n");

  if (y) {
    fprintf(stderr, "My error\n");
    // CHECK: KleeReportError.c:23: My error
    // CHECK: KleeReportError.c:23: My error
    // FIXME: Use FileCheck's relative line number syntax
    klee_report_error(__FILE__, __LINE__, "My error", "my.err");
  }

  return 0;
}
Ejemplo n.º 10
0
int main(int argc, char** argv) {
  int x = 54;
  klee_make_symbolic(&x, sizeof(x), "x");
  klee_assume(x == ASSUME_VALUE);

#ifdef PRINT_VALUE
  printf("x=%d\n", x);
#endif

  return 0;
}
Ejemplo n.º 11
0
int main(int argc, char **argv) {
  //- SETUP -//
  ssl_record ssl_records[100];

  for (int i = 1; i < 100; i++) {
    ssl_records[i].length  = 4;
    ssl_records[i].payload = (char*)malloc(4);
    *ssl_records[i].payload = "AAAA";
  }

  // Create a heartbeat message
  heartbeat *hb = (heartbeat*)malloc(sizeof(heartbeat));
  hb->length    = 256;
  hb->payload   = (char*)malloc(3);
  *hb->payload = (char*)":(";

  // Save it as ssl payload
  ssl_record *ssl = &ssl_records[0];
  klee_make_symbolic(ssl, sizeof(ssl_record), "ssl_record");
  ssl->length     = sizeof(heartbeat);
  ssl->payload    = (char*)hb;
  printf("HB size: %d\n", sizeof(heartbeat));

  //- HEARTBLEED EMULATION START -//

  // Recieve ssl record and read heartbeat message.
  ssl = &ssl_records[0];
  hb  = (heartbeat*)ssl->payload;
  int ln = hb->length;

  /*
  if (ssl->length < ln)
    ln = ssl->length;
  */

  // Create new heartbeat message to send back.
  heartbeat echo;
  echo.length  = ln;  // Same length as original hb message.
  echo.payload = (char*)malloc(ln);

  // Copy from original payload, withouth checking against ssl payload length.
  for (int i = 0; i < ln; i++) {
    echo.payload[i] = hb->payload[i];
  }
 
  //- HEARTBLEED EMULATION STOP -//
 
  char *p = echo.payload;
  for (int i = 0; i < echo.length; i++) {
    printf("%d\t%#02X\n",i, p[i]); 
  }
  
  return 0;
}
Ejemplo n.º 12
0
//	printf("out hi function\n");
///////////////////测试是否从网上的down下来
int main(int argc, char **argv) {
    int c ;
  klee_make_symbolic(&c, sizeof(c), "input111111");

  if(c > 100)
  {
	printf("into >100\n");		  
  }
  else
	printf("into <=100\n");
}
Ejemplo n.º 13
0
int main(void)
{
  klee_make_symbolic(keys, 5 * 5 * 5 * 5 * sizeof(int), "keys");
  
#ifdef TEST
  printf("result=%d\n",foo(400));
#else
  foo(400);
#endif
  return 0;
}
Ejemplo n.º 14
0
int klee_range(int begin, int end, const char* name) {
  int x;
  klee_make_symbolic(&x, sizeof x, name);
  if (x<begin || x>=end) {
    fprintf(stderr, 
            "KLEE: ERROR: invalid klee_range(%u,%u,%s) value, got: %u\n", 
            begin, end, name, x);
    abort();
  }
  return x;
}
Ejemplo n.º 15
0
int main() {
  // The input regular expression.
  char re[SIZE];
  
  // Make the input symbolic. 
  klee_make_symbolic(re, sizeof re, "re");

  // Try to match against a constant string "hello".
  strcmp(re, "hello1");

  return 0;
}
Ejemplo n.º 16
0
int main(int argc, char **argv) {
    int c ;
	int d;
// char *name;
 // name = (char *)malloc(sizeof(char) *2);
 
	kain();

  klee_make_symbolic(&c, sizeof(c), "inputccccccc");
//  klee_make_symbolic(name, sizeof(char)*2, "filename");
  pthread_t thread1;
  //malloc(sizeof(int));
  // putchar(2);
 // hi();
// 	printf(,"hi");
// strcmp(name, "hhi");
//
//
//
//
//
//
//
//
 	pthread_create(&thread1,NULL,hi,(void *)&c);
// 	pthread_create(0,NULL,0,0);
 
// 	fopen(name, "r");
// 	fopen("name", "r");
//
//
	if(d > 100)
		if(c > 0)
			printf("c main hi\n");
		else
			printf("c main cry\n");



/* 
   if(fopen(name, "r") == NULL)
   {
		printf("open error");		   
   }
   else
		printf("open succeed");
*/		

	pthread_join(thread1, NULL);

// return my_islower(c);
//	printf("main funciton out ok ok ok ok \n");
}
Ejemplo n.º 17
0
void *accessorThread(void *arg){
    
    int *result = (int*)malloc(sizeof(int)); klee_make_symbolic(result, sizeof(int), "result");
    *result = 0;
    
    while(*result < MAXVAL){
        swizzle(result);
        usleep(10 + (rand() % 100) );
    }
    
    pthread_exit(result);
}
Ejemplo n.º 18
0
int main(int argc, char **argv)
{
	int m;
	pthread_t thread;
			
	klee_make_symbolic(&m, sizeof(m), "mm");


	pthread_create(&thread,NULL, func, &m);
		

}
Ejemplo n.º 19
0
int main() {
  char buf[4];

  klee_make_symbolic(buf, sizeof buf, "buf");
  // CHECK: Hi\x00\x00
  klee_prefer_cex(buf, buf[0]=='H');
  klee_prefer_cex(buf, buf[1]=='i');
  klee_prefer_cex(buf, buf[2]=='\0');
  klee_prefer_cex(buf, buf[3]=='\0');

  return 0;
}
Ejemplo n.º 20
0
int main ()
{
  Char *buf;
  Char *pattern;
  Char *bound;

  Char A [MAXPATHLEN+1];
  Char B [PATTERNLEN];
  
  klee_make_symbolic(A, sizeof(A), "A");
  klee_make_symbolic(B, sizeof(B), "B");

  buf = A;
  pattern = B;

  bound = A + sizeof(A) - 1;

  glob2 (buf, buf, bound, pattern);

  return 0;
}
int main() {
  int a;
  klee_make_symbolic(&a, sizeof(a), "a");


char *tmp = getenv("KTEST_FILE");
FILE *file = fopen(".successful_test", "a");
fputs(tmp, file);
fputc('\n', file);
fclose(file);

  return get_sign(a);
} 
int main(){
  i=0;
  klee_make_symbolic(&i, sizeof(i), "i");
  if(i>0){
    while(i<20){
      a[i]=i;
      i=i+1;
    }
  } else {
      assert(0);
  }
  return 0;
}
Ejemplo n.º 23
0
int main() {
  char a[6] = "hello";
  unsigned i;

  klee_make_symbolic(&i, sizeof(i), "i");

  klee_assume(i <= 1);
  a[i] = 0;

  assert(a[3] != 0);

  return 0;
} 
Ejemplo n.º 24
0
Archivo: abort.c Proyecto: arges/vvklee
int main (int argc, char * argv[])
{

   char myStr[5];

   klee_make_symbolic(&myStr, sizeof(myStr), "myStr");   
   if(strcmp(myStr, "bye!") == 0)
   {
       // someone said bye, time to go! 
       abort();
   }

   return 0;
}
Ejemplo n.º 25
0
int main ()
{
  char uri [URI_SZ];
  int scheme;

  uri [URI_SZ-1] = EOS;
  scheme = LDAP_SZ + 2;
  
  klee_make_symbolic(uri, sizeof(uri), "uri");

  escape_absolute_uri (uri, scheme);

  return 0;
}
Ejemplo n.º 26
0
int main(int argc, char *argv[])
{
  int n, reverse=0, rem;
  printf("Enter an integer: ");
  klee_make_symbolic(&n, sizeof n, "n");
  while(n!=0)
  {
     rem=n%10;
     reverse=reverse*10+rem;
     n/=10;
  }
  printf("Reversed Number = %d",reverse);
  return 0;
}
Ejemplo n.º 27
0
int main(){
  int nodecount = 5;
  int edgecount = 5;
  int source = 0;
  int Source[5] = {0,0,0,3,4};
  int Dest[5] = {1,0,0,1,1};
  int Weight[5] = {0,1,2,3,4};
  int distance[5];
  klee_make_symbolic(distance, sizeof(distance), "distance"); 
  int x,y;
  int i,j;

  for(i = 0; i < nodecount; i++){
    if(i == source){
      distance[i] = 0;
    }
    else {
      distance[i] = INFINITY;
    }
  }

  for(i = 0; i < nodecount; i++)
    {
      for(j = 0; j < edgecount; j++)
        {
          x = Dest[j];
          y = Source[j];
          if(distance[x] > distance[y] + Weight[j])
            {
              distance[x] = distance[y] + Weight[j];
            }
        }
    }
  for(i = 0; i < edgecount; i++)
    {
      x = Dest[i];
      y = Source[i];
      if(distance[x] > distance[y] + Weight[i])
        {
          return 0;
        }
    }

  for(i = 0; i < nodecount; i++)
    {
      assert(distance[i]>=0);
    }

  return 0;
}
Ejemplo n.º 28
0
int main()
{
  int a;

  /* We make a symbolic */
  /* a = 30; */

  klee_make_symbolic(&a, sizeof(int), "a");
  klee_assume(a >= 0);
  klee_assume(a <= 30);
	      
  fib(a);
  return a;
}
Ejemplo n.º 29
0
int main() {
	unsigned char flag;
	int x = 0;
	klee_make_symbolic(&flag, sizeof(flag), "flag");

	if(flag > 10) {
		x = foo(x);
	} else if(flag == 0) {
		x = bar(x);
	} else {
		x = 2 * x;
	}
	return x; 
}
Ejemplo n.º 30
0
int main()
{	
    int N = 7;
    int i;
    int *a = malloc(N * sizeof(int));
    for (i = 0; i < N; i++) {
        int s;
        klee_make_symbolic(&s, sizeof(s), "s");
        a[i] = s;
    }
    //int a[] = {0, 0, 0};
    selectSort(a, N);
    free(a);
    return 0;
}