Hi all,
I am trying to run KLEE on gzip with symbolic files but klee seems to just
get stuck (even when giving the max-time parameter).
So i wrote a small toy program to run klee on.
At first trial i used fscanf function an klee got stuck on it as well. Then
when i changed the read function to fread(), everything worked fine and
klee generated the test cases.
Then i used the read() function (which is used by gzip), and the klee just
prints one test case with all 0's.
The command i am using is
*klee --libc=uclibc --posix-runtime ./de.bc --sym-files 1 160 A*
Any ideas how i can get the klee to work with read() / gzip.
I am attaching both the versions of my toy program.
Thanks
#include<stdio.h>
#include<string.h>
#include<malloc.h>
int main (int argc, char* argv[])
{
char *filename, *byteRead, temp, *O_Filename;
FILE *myfile;
byteRead = (char *)malloc(sizeof(char));
O_Filename = (char *)malloc(1024*sizeof(char));
if(argc!=0)
{
filename = argv[1];
myfile = fopen (filename, "rb");
if (myfile != NULL)
{
fread(byteRead,1,1,myfile);//printf("%c",*byteRead); /*//, "%c", byteRead);
temp=31;
if(*byteRead != temp)
{ printf("ID1 is wrong"); return 0; }
fread(byteRead,1,1,myfile);
temp=139;
if(*byteRead != temp)
{ printf("ID2 is wrong"); return 0; }
fread(byteRead,1,1,myfile);
temp=8;
if(*byteRead != temp)
{ printf("CM is wrong"); return 0; }
fread(byteRead,1,1,myfile);
temp=8;
if(*byteRead != temp)
{ printf("FLAG is wrong"); return 0; }
fread(byteRead,1,1,myfile);
temp=0;
while(*byteRead != temp)
{
strcat(O_Filename,byteRead);
fread(byteRead,1,1,myfile);
}
strcat(O_Filename,byteRead);
printf("%s\n,Success", O_Filename);
}
else
{ printf("Error in opening file"); }
fclose(myfile);
}
else
{
printf("No input file specified");
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#define BUFSIZE 1
int main (int argc, char* argv[])
{
char *filename, *byteRead, temp, temp1, *O_Filename;
FILE *myfile;
int ifd;
size_t r;
byteRead = (char *)malloc(sizeof(char));
O_Filename = (char *)malloc(1024*sizeof(char));
if(argc!=0)
{
filename = argv[1];
//myfile = fopen (filename, "rb");
ifd = open("hello.pdf.zip", O_RDONLY);
if (ifd != 0)
{
r = read(ifd,byteRead,BUFSIZE);
temp=31;
if(*byteRead != temp)
{ printf("ID1 is wrong"); return 0; }
r = read(ifd,byteRead,BUFSIZE);
temp=139;
if(*byteRead != temp)
{ printf("ID2 is wrong"); printf("\nID2%s\n", byteRead); return 0; }
r = read(ifd,byteRead,BUFSIZE);
temp=8;
if(*byteRead != temp)
{ printf("CM is wrong"); return 0; }
r = read(ifd,byteRead,BUFSIZE);
temp=8;
if(*byteRead != temp)
{ printf("FLAG is wrong"); return 0; }
r = read(ifd,byteRead,BUFSIZE);
temp=0;
while(*byteRead != temp)
{
strcat(O_Filename,byteRead);
r = read(ifd,byteRead,BUFSIZE);
}
strcat(O_Filename,byteRead);
printf("%s Success\n", O_Filename);
}
else
{ printf("Error in opening file"); }
close(ifd);
}
else
{
printf("No input file specified");
}
return 0;
}
_______________________________________________
klee-dev mailing list
[email protected]
https://mailman.ic.ac.uk/mailman/listinfo/klee-dev