@@ -597,13 +597,13 @@ void *memcpy(void *dst, const void *src, size_t n)
597
597
__CPROVER_precondition (__CPROVER_POINTER_OBJECT (dst )!=
598
598
__CPROVER_POINTER_OBJECT (src ),
599
599
"memcpy src/dst overlap" );
600
+ __CPROVER_precondition (__CPROVER_r_ok (src , n ),
601
+ "memcpy source region readable" );
602
+ __CPROVER_precondition (__CPROVER_w_ok (dst , n ),
603
+ "memcpy destination region writeable" );
600
604
601
605
if (n > 0 )
602
606
{
603
- (void )* (char * )dst ; // check that the memory is accessible
604
- (void )* (const char * )src ; // check that the memory is accessible
605
- (void )* (((char * )dst ) + n - 1 ); // check that the memory is accessible
606
- (void )* (((const char * )src ) + n - 1 ); // check that the memory is accessible
607
607
//for(__CPROVER_size_t i=0; i<n ; i++) ((char *)dst)[i]=((const char *)src)[i];
608
608
char src_n [n ];
609
609
__CPROVER_array_copy (src_n , (char * )src );
@@ -639,14 +639,14 @@ void *__builtin___memcpy_chk(void *dst, const void *src, __CPROVER_size_t n, __C
639
639
__CPROVER_precondition (__CPROVER_POINTER_OBJECT (dst )!=
640
640
__CPROVER_POINTER_OBJECT (src ),
641
641
"memcpy src/dst overlap" );
642
+ __CPROVER_precondition (__CPROVER_r_ok (src , n ),
643
+ "memcpy source region readable" );
644
+ __CPROVER_precondition (__CPROVER_w_ok (dst , n ),
645
+ "memcpy destination region writeable" );
642
646
(void )size ;
643
647
644
648
if (n > 0 )
645
649
{
646
- (void )* (char * )dst ; // check that the memory is accessible
647
- (void )* (const char * )src ; // check that the memory is accessible
648
- (void )* (((char * )dst ) + n - 1 ); // check that the memory is accessible
649
- (void )* (((const char * )src ) + n - 1 ); // check that the memory is accessible
650
650
//for(__CPROVER_size_t i=0; i<n ; i++) ((char *)dst)[i]=((const char *)src)[i];
651
651
char src_n [n ];
652
652
__CPROVER_array_copy (src_n , (char * )src );
@@ -685,11 +685,11 @@ void *memset(void *s, int c, size_t n)
685
685
else
686
686
__CPROVER_is_zero_string (s )= 0 ;
687
687
#else
688
+ __CPROVER_precondition (__CPROVER_w_ok (s , n ),
689
+ "memset destination region writeable" );
688
690
689
691
if (n > 0 )
690
692
{
691
- (void )* (char * )s ; // check that the memory is accessible
692
- (void )* (((char * )s ) + n - 1 ); // check that the memory is accessible
693
693
//char *sp=s;
694
694
//for(__CPROVER_size_t i=0; i<n ; i++) sp[i]=c;
695
695
unsigned char s_n [n ];
@@ -724,11 +724,11 @@ void *__builtin_memset(void *s, int c, __CPROVER_size_t n)
724
724
__CPROVER_is_zero_string (s )= 0 ;
725
725
}
726
726
#else
727
+ __CPROVER_precondition (__CPROVER_w_ok (s , n ),
728
+ "memset destination region writeable" );
727
729
728
730
if (n > 0 )
729
731
{
730
- (void )* (char * )s ; // check that the memory is accessible
731
- (void )* (((char * )s ) + n - 1 ); // check that the memory is accessible
732
732
//char *sp=s;
733
733
//for(__CPROVER_size_t i=0; i<n ; i++) sp[i]=c;
734
734
unsigned char s_n [n ];
@@ -763,12 +763,12 @@ void *__builtin___memset_chk(void *s, int c, __CPROVER_size_t n, __CPROVER_size_
763
763
else
764
764
__CPROVER_is_zero_string (s )= 0 ;
765
765
#else
766
+ __CPROVER_precondition (__CPROVER_w_ok (s , n ),
767
+ "memset destination region writeable" );
766
768
(void )size ;
767
769
768
770
if (n > 0 )
769
771
{
770
- (void )* (char * )s ; // check that the memory is accessible
771
- (void )* (((char * )s ) + n - 1 ); // check that the memory is accessible
772
772
//char *sp=s;
773
773
//for(__CPROVER_size_t i=0; i<n ; i++) sp[i]=c;
774
774
unsigned char s_n [n ];
@@ -804,13 +804,13 @@ void *memmove(void *dest, const void *src, size_t n)
804
804
else
805
805
__CPROVER_is_zero_string (dest )= 0 ;
806
806
#else
807
+ __CPROVER_precondition (__CPROVER_r_ok (src , n ),
808
+ "memmove source region readable" );
809
+ __CPROVER_precondition (__CPROVER_w_ok (dest , n ),
810
+ "memmove destination region writeable" );
807
811
808
812
if (n > 0 )
809
813
{
810
- (void )* (char * )dest ; // check that the memory is accessible
811
- (void )* (const char * )src ; // check that the memory is accessible
812
- (void )* (((char * )dest ) + n - 1 ); // check that the memory is accessible
813
- (void )* (((const char * )src ) + n - 1 ); // check that the memory is accessible
814
814
char src_n [n ];
815
815
__CPROVER_array_copy (src_n , (char * )src );
816
816
__CPROVER_array_replace ((char * )dest , src_n );
@@ -848,14 +848,14 @@ void *__builtin___memmove_chk(void *dest, const void *src, size_t n, __CPROVER_s
848
848
__CPROVER_is_zero_string (dest )= 0 ;
849
849
}
850
850
#else
851
+ __CPROVER_precondition (__CPROVER_r_ok (src , n ),
852
+ "memmove source region readable" );
853
+ __CPROVER_precondition (__CPROVER_w_ok (dest , n ),
854
+ "memmove destination region writeable" );
851
855
(void )size ;
852
856
853
857
if (n > 0 )
854
858
{
855
- (void )* (char * )dest ; // check that the memory is accessible
856
- (void )* (const char * )src ; // check that the memory is accessible
857
- (void )* (((char * )dest ) + n - 1 ); // check that the memory is accessible
858
- (void )* (((const char * )src ) + n - 1 ); // check that the memory is accessible
859
859
char src_n [n ];
860
860
__CPROVER_array_copy (src_n , (char * )src );
861
861
__CPROVER_array_replace ((char * )dest , src_n );
@@ -883,6 +883,11 @@ inline int memcmp(const void *s1, const void *s2, size_t n)
883
883
__CPROVER_precondition (__CPROVER_buffer_size (s2 )>=n ,
884
884
"memcmp buffer overflow of 2nd argument" );
885
885
#else
886
+ __CPROVER_precondition (__CPROVER_r_ok (s1 , n ),
887
+ "memcmp region 1 readable" );
888
+ __CPROVER_precondition (__CPROVER_r_ok (s2 , n ),
889
+ "memcpy region 2 readable" );
890
+
886
891
const unsigned char * sc1 = s1 , * sc2 = s2 ;
887
892
for (; n != 0 ; n -- )
888
893
{
0 commit comments