欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

bug:越界访问导致ERROR: AddressSanitizer: heap-buffer-overflow on address

程序员文章站 2022-07-13 13:23:23
...
==30==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000000054 at pc 0x00000040d6e7 bp 0x7fffd87fd2f0 sp 0x7fffd87fd2e8
READ of

越界访问了,注意数组等的边界,len-1

 

 

bug:越界访问导致ERROR: AddressSanitizer: heap-buffer-overflow on address

 

 

=================================================================
==30==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000000054 at pc 0x00000040d6e7 bp 0x7fffd87fd2f0 sp 0x7fffd87fd2e8
READ of size 4 at 0x603000000054 thread T0
    #1 0x7f96f8e952e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)

0x603000000054 is located 0 bytes to the right of 20-byte region [0x603000000040,0x603000000054)
allocated by thread T0 here:
    #0 0x7f96fa8bace0 in operator new(unsigned long) (/usr/local/lib64/libasan.so.5+0xe9ce0)
    #2 0x7f96f8e952e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)

Shadow bytes around the buggy address:
  0x0c067fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c067fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c067fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c067fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c067fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c067fff8000: fa fa 00 00 00 00 fa fa 00 00[04]fa fa fa fa fa
  0x0c067fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==30==ABORTING

 

如何利用Sanitizer解决Android开发中遇到的Bug?