@@ -25,35 +25,19 @@ pub enum InboundsCheck {
2525/// Used by `check_in_alloc` to indicate context of check
2626#[ derive( Debug , Copy , Clone , RustcEncodable , RustcDecodable , HashStable ) ]
2727pub enum CheckInAllocMsg {
28- ReadCStr ,
29- CheckBytes ,
30- WriteBytes ,
31- WriteRepeat ,
32- ReadScalar ,
33- WriteScalar ,
34- SlicePatCoveredByConst ,
35- ReadDiscriminant ,
36- CheckAlign ,
37- ReadBytes ,
38- CopyRepeatedly ,
39- CheckBounds ,
28+ MemoryAccess ,
29+ NullPointer ,
30+ PointerArithmetic ,
31+ OutOfBounds ,
4032}
4133
4234impl Display for CheckInAllocMsg {
4335 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
4436 write ! ( f, "{}" , match * self {
45- CheckInAllocMsg :: ReadCStr => "read C str" ,
46- CheckInAllocMsg :: CheckBytes => "check bytes" ,
47- CheckInAllocMsg :: WriteBytes => "write bytes" ,
48- CheckInAllocMsg :: WriteRepeat => "write repeat" ,
49- CheckInAllocMsg :: ReadScalar => "read scalar" ,
50- CheckInAllocMsg :: WriteScalar => "write scalar" ,
51- CheckInAllocMsg :: SlicePatCoveredByConst => "slice pat covered by const" ,
52- CheckInAllocMsg :: ReadDiscriminant => "read discriminant" ,
53- CheckInAllocMsg :: CheckAlign => "check align" ,
54- CheckInAllocMsg :: ReadBytes => "read bytes" ,
55- CheckInAllocMsg :: CopyRepeatedly => "copy repeatedly" ,
56- CheckInAllocMsg :: CheckBounds => "check bounds" ,
37+ CheckInAllocMsg :: MemoryAccess => "memory access" ,
38+ CheckInAllocMsg :: NullPointer => "null pointer" ,
39+ CheckInAllocMsg :: PointerArithmetic => "pointer arithmetic" ,
40+ CheckInAllocMsg :: OutOfBounds => "out of bounds" ,
5741 } )
5842 }
5943}
@@ -311,7 +295,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
311295 // Go through `get_bytes` for checks and AllocationExtra hooks.
312296 // We read the null, so we include it in the request, but we want it removed
313297 // from the result!
314- Ok ( & self . get_bytes ( cx, ptr, size_with_null, CheckInAllocMsg :: ReadCStr ) ?[ ..size] )
298+ Ok ( & self . get_bytes ( cx, ptr, size_with_null, CheckInAllocMsg :: NullPointer ) ?[ ..size] )
315299 }
316300 None => err ! ( UnterminatedCString ( ptr. erase_tag( ) ) ) ,
317301 }
@@ -331,7 +315,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
331315 where Extra : AllocationExtra < Tag , MemoryExtra >
332316 {
333317 // Check bounds and relocations on the edges
334- self . get_bytes_with_undef_and_ptr ( cx, ptr, size, CheckInAllocMsg :: CheckBytes ) ?;
318+ self . get_bytes_with_undef_and_ptr ( cx, ptr, size, CheckInAllocMsg :: OutOfBounds ) ?;
335319 // Check undef and ptr
336320 if !allow_ptr_and_undef {
337321 self . check_defined ( ptr, size) ?;
@@ -353,7 +337,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
353337 where Extra : AllocationExtra < Tag , MemoryExtra >
354338 {
355339 let bytes = self . get_bytes_mut ( cx, ptr, Size :: from_bytes ( src. len ( ) as u64 ) ,
356- CheckInAllocMsg :: WriteBytes ) ?;
340+ CheckInAllocMsg :: MemoryAccess ) ?;
357341 bytes. clone_from_slice ( src) ;
358342 Ok ( ( ) )
359343 }
@@ -369,7 +353,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
369353 // FIXME: Working around https://github.com/rust-lang/rust/issues/56209
370354 where Extra : AllocationExtra < Tag , MemoryExtra >
371355 {
372- let bytes = self . get_bytes_mut ( cx, ptr, count, CheckInAllocMsg :: WriteRepeat ) ?;
356+ let bytes = self . get_bytes_mut ( cx, ptr, count, CheckInAllocMsg :: MemoryAccess ) ?;
373357 for b in bytes {
374358 * b = val;
375359 }
@@ -394,7 +378,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
394378 where Extra : AllocationExtra < Tag , MemoryExtra >
395379 {
396380 // get_bytes_unchecked tests relocation edges
397- let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size, CheckInAllocMsg :: ReadScalar ) ?;
381+ let bytes = self . get_bytes_with_undef_and_ptr ( cx, ptr, size, CheckInAllocMsg :: PointerArithmetic ) ?;
398382 // Undef check happens *after* we established that the alignment is correct.
399383 // We must not return Ok() for unaligned pointers!
400384 if self . check_defined ( ptr, size) . is_err ( ) {
@@ -471,7 +455,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
471455 } ;
472456
473457 let endian = cx. data_layout ( ) . endian ;
474- let dst = self . get_bytes_mut ( cx, ptr, type_size, CheckInAllocMsg :: WriteScalar ) ?;
458+ let dst = self . get_bytes_mut ( cx, ptr, type_size, CheckInAllocMsg :: PointerArithmetic ) ?;
475459 write_target_uint ( endian, dst, bytes) . unwrap ( ) ;
476460
477461 // See if we have to also write a relocation
0 commit comments