int main(int argc, char *argv[]) { char **vector; int args; s2e_disable_all_apic_interrupts(); s2e_enable_forking(); s2e_make_symbolic(&args, sizeof(args), "Number of arguments"); if (args < 1 || args > 4) { s2e_get_example(&args, sizeof(args)); printf("Bad value for args: %d\n", args); s2e_kill_state(0, "bad value for args"); return 2; } printf("Good value for args\n"); fflush(stdout); args= 5; s2e_get_example(&args, sizeof(args)); printf("Got value for args: %d\n", args); fflush(stdout); printf("Before malloc vector\n"); vector= malloc((args+1)*sizeof(*vector)); printf("After malloc vector\n"); s2e_kill_state(0, "after malloc"); }
static void handler_exemplify(const char **args) { #define BUF_SIZE 32 char buffer[BUF_SIZE] = { 0 }; unsigned int i; while (fgets(buffer, sizeof(buffer), stdin)) { for (i = 0; i < BUF_SIZE; ++i) { if (s2e_is_symbolic(&buffer[i], sizeof(buffer[i]))) { s2e_get_example(&buffer[i], sizeof(buffer[i])); } } fputs(buffer, stdout); memset(buffer, 0, sizeof(buffer)); } }
int main (void) { char buf[32]; memset (buf, '\0', sizeof (buf) ); char given; char symb; // for non-symbolic: /* char str[3]; memset (str, '\0', 3); printf("Enter two characters: "); if (!fgets(str, sizeof(str), stdin)) return 1; symb = str[0]; given = str[1]; */ // for symbolic: //s2e_disable_all_apic_interrupts(); // make faster given = 'a'; s2e_enable_forking (); // Enable forking on symbolic conditions. s2e_make_symbolic (&(symb), 1 * sizeof (char), "symb"); // saves state // forks to creates a new state with symbolic (random) values for str[0] and str[1] // note, this means it only created and ran 1 set of symbolic value snprintf (buf, sizeof (buf), "Running S2E Tutorial1\n"); /*s2e_get_example (&(symb), 1 * sizeof (char) ); // gets the symbolic values that were used which reached this point snprintf (buf, sizeof (buf), "Running S2E Tutorial1:%02x%02x%c%c:\n", (unsigned char) symb, (unsigned char) given, symb, given);*/ s2e_message (buf); printf ("%s\n", buf); if (symb == '\0') { printf ("No input char\n"); s2e_get_example (&(symb), 1 * sizeof (char) ); // gets the symbolic values that were used which reached this point snprintf (buf, sizeof (buf), "s2e_get_example4:%02x%02x%c%c:\n", (unsigned char) symb, (unsigned char) given, symb, given); s2e_warning (buf); printf ("%s\n", buf); } else { s2e_get_example (&(symb), 1 * sizeof (char) ); // gets the symbolic values that were used which reached this point snprintf (buf, sizeof (buf), "s2e_get_example1:%02x%02x%c%c:\n", (unsigned char) symb, (unsigned char) given, symb, given); s2e_warning (buf); printf ("%s\n", buf); if (symb == given) { //s2e_warning ("symb equals 1\n"); printf ("Chars are the same: %c == %c\n", symb, given); s2e_get_example (&(symb), 1 * sizeof (char) ); // gets the symbolic values that were used which reached this point snprintf (buf, sizeof (buf), "s2e_get_example2:%02x%02x%c%c:\n", (unsigned char) symb, (unsigned char) given, symb, given); s2e_warning (buf); printf ("%s\n", buf); } } //s2e_disable_forking (); s2e_get_example (&(symb), 1 * sizeof (char) ); // gets the symbolic values that were used which reached this point snprintf (buf, sizeof (buf), "s2e_get_example3:%02x%02x%c%c:\n", (unsigned char) symb, (unsigned char) given, symb, given); s2e_warning (buf); printf ("%s\n", buf); s2e_kill_state (0, "program terminated"); return 0; }