@@ -764,24 +764,28 @@ class TailOverwrittenReport : public BaseReport {
764
764
uptr orig_size, const u8 *expected)
765
765
: BaseReport(stack, flags()->halt_on_error, tagged_addr, 0),
766
766
orig_size(orig_size),
767
- expected(expected) {}
767
+ tail_size(kShadowAlignment - (orig_size % kShadowAlignment )) {
768
+ CHECK_GT (tail_size, 0U );
769
+ CHECK_LT (tail_size, kShadowAlignment );
770
+ internal_memcpy (tail_copy,
771
+ reinterpret_cast <u8 *>(untagged_addr + orig_size),
772
+ tail_size);
773
+ internal_memcpy (actual_expected, expected, tail_size);
774
+ // Short granule is stashed in the last byte of the magic string. To avoid
775
+ // confusion, make the expected magic string contain the short granule tag.
776
+ if (orig_size % kShadowAlignment != 0 )
777
+ actual_expected[tail_size - 1 ] = ptr_tag;
778
+ }
768
779
~TailOverwrittenReport ();
769
780
770
781
private:
771
- const uptr orig_size;
772
- const u8 *expected;
782
+ const uptr orig_size = 0 ;
783
+ const uptr tail_size = 0 ;
784
+ u8 actual_expected[kShadowAlignment ] = {};
785
+ u8 tail_copy[kShadowAlignment ] = {};
773
786
};
774
787
775
788
TailOverwrittenReport::~TailOverwrittenReport () {
776
- uptr tail_size = kShadowAlignment - (orig_size % kShadowAlignment );
777
- u8 actual_expected[kShadowAlignment ];
778
- internal_memcpy (actual_expected, expected, tail_size);
779
- // Short granule is stashed in the last byte of the magic string. To avoid
780
- // confusion, make the expected magic string contain the short granule tag.
781
- if (orig_size % kShadowAlignment != 0 ) {
782
- actual_expected[tail_size - 1 ] = ptr_tag;
783
- }
784
-
785
789
Decorator d;
786
790
Printf (" %s" , d.Error ());
787
791
const char *bug_type = " allocation-tail-overwritten" ;
@@ -803,9 +807,7 @@ TailOverwrittenReport::~TailOverwrittenReport() {
803
807
}
804
808
805
809
InternalScopedString s;
806
- CHECK_GT (tail_size, 0U );
807
- CHECK_LT (tail_size, kShadowAlignment );
808
- u8 *tail = reinterpret_cast <u8*>(untagged_addr + orig_size);
810
+ u8 *tail = tail_copy;
809
811
s.AppendF (" Tail contains: " );
810
812
for (uptr i = 0 ; i < kShadowAlignment - tail_size; i++) s.AppendF (" .. " );
811
813
for (uptr i = 0 ; i < tail_size; i++) s.AppendF (" %02x " , tail[i]);
0 commit comments