Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
6badae9d
Commit
6badae9d
authored
5 years ago
by
Andre Maroneze
Browse files
Options
Downloads
Patches
Plain Diff
[Libc] fix spec of strncpy
parent
8dacf071
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
share/libc/string.h
+1
-1
1 addition, 1 deletion
share/libc/string.h
tests/libc/string_h.c
+14
-0
14 additions, 0 deletions
tests/libc/string_h.c
with
15 additions
and
1 deletion
share/libc/string.h
+
1
−
1
View file @
6badae9d
...
@@ -354,7 +354,7 @@ extern char *strerror(int errnum);
...
@@ -354,7 +354,7 @@ extern char *strerror(int errnum);
extern
char
*
strcpy
(
char
*
restrict
dest
,
const
char
*
restrict
src
);
extern
char
*
strcpy
(
char
*
restrict
dest
,
const
char
*
restrict
src
);
/*@
/*@
@ requires valid_string_src: valid_read_string(src);
@ requires valid_
n
string_src: valid_read_
n
string(src
, n
);
@ requires room_nstring: \valid(dest+(0 .. n-1));
@ requires room_nstring: \valid(dest+(0 .. n-1));
@ requires separation:
@ requires separation:
@ \separated(dest+(0..n-1), src+(0..n-1));
@ \separated(dest+(0..n-1), src+(0..n-1));
...
...
This diff is collapsed.
Click to expand it.
tests/libc/string_h.c
+
14
−
0
View file @
6badae9d
...
@@ -107,6 +107,19 @@ void test_strtok_r() {
...
@@ -107,6 +107,19 @@ void test_strtok_r() {
}
}
}
}
void
test_strncpy
()
{
char
src
[]
=
{
'a'
,
'b'
,
'c'
};
char
dst
[
3
];
strncpy
(
dst
,
src
,
3
);
char
src2
[
3
];
src2
[
0
]
=
'a'
;
src2
[
1
]
=
'b'
;
if
(
nondet
)
{
strncpy
(
dst
,
src2
,
3
);
//@ assert unreachable: \false;
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
test_strcmp
();
test_strcmp
();
...
@@ -125,5 +138,6 @@ int main(int argc, char **argv)
...
@@ -125,5 +138,6 @@ int main(int argc, char **argv)
size_t
r3
=
strlcat
(
buf2
,
buf
,
32
);
size_t
r3
=
strlcat
(
buf2
,
buf
,
32
);
char
*
strsig
=
strsignal
(
1
);
char
*
strsig
=
strsignal
(
1
);
//@ assert valid_read_string(strsig);
//@ assert valid_read_string(strsig);
test_strncpy
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment