Skip to content

Commit a021bf6

Browse files
authored
Merge pull request #7904 from tautschnig/features/chk
C library: model and test several __*_chk variants
2 parents 801fa73 + d95917d commit a021bf6

File tree

15 files changed

+305
-34
lines changed

15 files changed

+305
-34
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
KNOWNBUG
2+
main.c
3+
--pointer-check --bounds-check -D_FORTIFY_SOURCE=2 -D__OPTIMIZE__=2 --unwindset fgets:0
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
\[main.assertion.3\] line 16 assertion p\[1\] == 'b': FAILURE
8+
\*\* 1 of \d+ failed
9+
--
10+
^\*\*\*\* WARNING: no body for function __fgets_chk
11+
^warning: ignoring
12+
--
13+
Our asm renaming results in fgets and its alias being one and the same function
14+
to us, so we end up recursing in glibc's fgets wrapper.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check -D_FORTIFY_SOURCE=2 -D__OPTIMIZE__=2
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^\*\*\*\* WARNING: no body for function __fprintf_chk
9+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check -D_FORTIFY_SOURCE=2 -D__OPTIMIZE__=2 --unwindset fread:0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^\*\*\*\* WARNING: no body for function __fread_chk
9+
^warning: ignoring

regression/cbmc-library/fread-01/main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
int main()
55
{
6-
fread();
7-
assert(0);
6+
FILE *f = fdopen(0, "r");
7+
if(!f)
8+
return 1;
9+
10+
char buffer[3];
11+
size_t result = fread(buffer, 3, 1, f);
12+
assert(result <= 3);
13+
14+
fclose(f);
15+
816
return 0;
917
}

regression/cbmc-library/fread-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--pointer-check --bounds-check
44
^EXIT=0$
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check -D_FORTIFY_SOURCE=2 -D__OPTIMIZE__=2
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\*\* 1 of \d+ failed
7+
^VERIFICATION FAILED$
8+
--
9+
^\*\*\*\* WARNING: no body for function __printf_chk
10+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check -D_FORTIFY_SOURCE=2 -D__OPTIMIZE__=2
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^\*\*\*\* WARNING: no body for function __syslog_chk
9+
^warning: ignoring
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#include <assert.h>
2-
#include <syslog.h>
2+
#ifndef _WIN32
3+
# include <syslog.h>
4+
#else
5+
void syslog(int priority, const char *format, ...);
6+
#endif
37

4-
int main()
8+
int main(int argc, char *argv[])
59
{
6-
syslog();
7-
assert(0);
10+
int some_priority;
11+
syslog(some_priority, "%d\n", argc);
812
return 0;
913
}

regression/cbmc-library/syslog-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--pointer-check --bounds-check
44
^EXIT=0$
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check -D_FORTIFY_SOURCE=2 -D__OPTIMIZE__=2
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^\*\*\*\* WARNING: no body for function __vfprintf_chk
9+
^warning: ignoring

0 commit comments

Comments
 (0)