@@ -11,14 +11,14 @@ __CPROVER_HIDE:;
11
11
__CPROVER_buffer_size (dst ) > __CPROVER_zero_string_length (src ),
12
12
"strcpy buffer overflow" );
13
13
__CPROVER_precondition (
14
- __CPROVER_buffer_size (dst ) == s , "builtin object size" );
14
+ s == ~(__CPROVER_size_t )0 || __CPROVER_buffer_size (dst ) == s ,
15
+ "builtin object size" );
15
16
dst [__CPROVER_zero_string_length (src )] = 0 ;
16
17
__CPROVER_is_zero_string (dst ) = 1 ;
17
18
__CPROVER_zero_string_length (dst ) = __CPROVER_zero_string_length (src );
18
19
#else
19
20
__CPROVER_precondition (
20
- __CPROVER_POINTER_OBJECT (dst ) != __CPROVER_POINTER_OBJECT (src ) ||
21
- (src >= dst + s ) || (dst >= src + s ),
21
+ __CPROVER_POINTER_OBJECT (dst ) != __CPROVER_POINTER_OBJECT (src ),
22
22
"strcpy src/dst overlap" );
23
23
__CPROVER_size_t i = 0 ;
24
24
char ch ;
@@ -45,7 +45,8 @@ __CPROVER_HIDE:;
45
45
__CPROVER_precondition (
46
46
__CPROVER_is_zero_string (src ), "strcat zero-termination of 2nd argument" );
47
47
__CPROVER_precondition (
48
- __CPROVER_buffer_size (dst ) == s , "builtin object size" );
48
+ s == ~(__CPROVER_size_t )0 || __CPROVER_buffer_size (dst ) == s ,
49
+ "builtin object size" );
49
50
new_size =
50
51
__CPROVER_zero_string_length (dst ) + __CPROVER_zero_string_length (src );
51
52
__CPROVER_assert (
@@ -58,8 +59,7 @@ __CPROVER_HIDE:;
58
59
__CPROVER_zero_string_length (dst ) = new_size ;
59
60
#else
60
61
__CPROVER_precondition (
61
- __CPROVER_POINTER_OBJECT (dst ) != __CPROVER_POINTER_OBJECT (src ) ||
62
- (src >= dst + s ) || (dst >= src + s ),
62
+ __CPROVER_POINTER_OBJECT (dst ) != __CPROVER_POINTER_OBJECT (src ),
63
63
"strcat src/dst overlap" );
64
64
__CPROVER_size_t i = 0 ;
65
65
while (dst [i ] != 0 )
@@ -91,7 +91,8 @@ __CPROVER_HIDE:;
91
91
__CPROVER_is_zero_string (src ) || __CPROVER_buffer_size (src ) >= n ,
92
92
"strncat zero-termination of 2nd argument" );
93
93
__CPROVER_precondition (
94
- __CPROVER_buffer_size (dst ) == s , "builtin object size" );
94
+ s == ~(__CPROVER_size_t )0 || __CPROVER_buffer_size (dst ) == s ,
95
+ "builtin object size" );
95
96
additional = (n < __CPROVER_zero_string_length (src ))
96
97
? n
97
98
: __CPROVER_zero_string_length (src );
@@ -107,8 +108,7 @@ __CPROVER_HIDE:;
107
108
__CPROVER_zero_string_length (dst ) = new_size ;
108
109
#else
109
110
__CPROVER_precondition (
110
- __CPROVER_POINTER_OBJECT (dst ) != __CPROVER_POINTER_OBJECT (src ) ||
111
- (src >= dst + s ) || (dst >= src + s ),
111
+ __CPROVER_POINTER_OBJECT (dst ) != __CPROVER_POINTER_OBJECT (src ),
112
112
"strncat src/dst overlap" );
113
113
114
114
__CPROVER_size_t i = 0 ;
@@ -220,7 +220,8 @@ __CPROVER_HIDE:;
220
220
__CPROVER_precondition (
221
221
__CPROVER_buffer_size (dst ) >= n , "strncpy buffer overflow" );
222
222
__CPROVER_precondition (
223
- __CPROVER_buffer_size (dst ) == object_size , "strncpy object size" );
223
+ object_size == ~(size_t )0 || __CPROVER_buffer_size (dst ) == object_size ,
224
+ "strncpy object size" );
224
225
__CPROVER_is_zero_string (dst ) = __CPROVER_zero_string_length (src ) < n ;
225
226
__CPROVER_zero_string_length (dst ) = __CPROVER_zero_string_length (src );
226
227
#else
@@ -660,7 +661,8 @@ void *__builtin___memcpy_chk(void *dst, const void *src, __CPROVER_size_t n, __C
660
661
__CPROVER_precondition (
661
662
__CPROVER_buffer_size (dst ) >= n , "memcpy buffer overflow" );
662
663
__CPROVER_precondition (
663
- __CPROVER_buffer_size (dst ) == s , "builtin object size" );
664
+ size == ~(__CPROVER_size_t )0 || __CPROVER_buffer_size (dst ) == size ,
665
+ "builtin object size" );
664
666
// for(size_t i=0; i<n ; i++) dst[i]=src[i];
665
667
if (__CPROVER_is_zero_string (src ) && n > __CPROVER_zero_string_length (src ))
666
668
{
@@ -782,12 +784,13 @@ void *__builtin_memset(void *s, int c, __CPROVER_size_t n)
782
784
783
785
void * __builtin___memset_chk (void * s , int c , __CPROVER_size_t n , __CPROVER_size_t size )
784
786
{
785
- __CPROVER_HIDE :;
786
- #ifdef __CPROVER_STRING_ABSTRACTION
787
+ __CPROVER_HIDE :;
788
+ #ifdef __CPROVER_STRING_ABSTRACTION
787
789
__CPROVER_precondition (__CPROVER_buffer_size (s )>=n ,
788
790
"memset buffer overflow" );
789
- __CPROVER_precondition (__CPROVER_buffer_size (s )== size ,
790
- "builtin object size" );
791
+ __CPROVER_precondition (
792
+ size == ~(__CPROVER_size_t )0 || __CPROVER_buffer_size (s ) == size ,
793
+ "builtin object size" );
791
794
// for(size_t i=0; i<n ; i++) s[i]=c;
792
795
if (__CPROVER_is_zero_string (s ) &&
793
796
n > __CPROVER_zero_string_length (s ))
@@ -801,7 +804,7 @@ void *__builtin___memset_chk(void *s, int c, __CPROVER_size_t n, __CPROVER_size_
801
804
}
802
805
else
803
806
__CPROVER_is_zero_string (s )= 0 ;
804
- #else
807
+ #else
805
808
__CPROVER_precondition (__CPROVER_w_ok (s , n ),
806
809
"memset destination region writeable" );
807
810
(void )size ;
@@ -814,7 +817,7 @@ void *__builtin___memset_chk(void *s, int c, __CPROVER_size_t n, __CPROVER_size_
814
817
__CPROVER_array_set (s_n , (unsigned char )c );
815
818
__CPROVER_array_replace ((unsigned char * )s , s_n );
816
819
}
817
- #endif
820
+ #endif
818
821
return s ;
819
822
}
820
823
@@ -873,8 +876,9 @@ void *__builtin___memmove_chk(void *dest, const void *src, size_t n, __CPROVER_s
873
876
#ifdef __CPROVER_STRING_ABSTRACTION
874
877
__CPROVER_precondition (__CPROVER_buffer_size (src )>=n ,
875
878
"memmove buffer overflow" );
876
- __CPROVER_precondition (__CPROVER_buffer_size (dest )== size ,
877
- "builtin object size" );
879
+ __CPROVER_precondition (
880
+ size == ~(__CPROVER_size_t )0 || __CPROVER_buffer_size (dest ) == size ,
881
+ "builtin object size" );
878
882
// dst = src (with overlap allowed)
879
883
if (__CPROVER_is_zero_string (src ) &&
880
884
n > __CPROVER_zero_string_length (src ))
0 commit comments