-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced substring_extraction, added new regression test
- Loading branch information
1 parent
01a87e8
commit 67ff0cf
Showing
3 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// PARAM: --disable ana.base.limit-string-addresses --enable ana.int.interval --enable ana.base.arrays.nullbytes --set ana.activated[+] substr | ||
|
||
#include <goblint.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
int main() { | ||
example1(); | ||
|
||
return 0; | ||
} | ||
|
||
void example1() { | ||
char s1[] = "string"; | ||
char s2[100]; | ||
s2[42] = '\0'; | ||
|
||
if (rand() == 42) { | ||
strcpy(s2, "C-"); | ||
strcat(s2, s1); | ||
} else { | ||
strcpy(s2, "sub"); | ||
strncat(s2, s1, 20); | ||
} | ||
|
||
char* s3 = strstr(s2, s1); | ||
__goblint_check(s3 != NULL); | ||
|
||
size_t len = strlen(s3); | ||
__goblint_check(len >= 0); | ||
__goblint_check(len <= 42); | ||
} |