Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. cat ubsan.c && gcc ubsan.c -fsanitize=address -g && ./a.out
  2. int main(int argc, char **argv)
  3. {
  4. int *items = (int[]) {1, 2, 3};
  5.  
  6. switch (argc)
  7. {
  8. case 0:
  9. items = (int[]) {999};
  10. break;
  11. default:
  12. items = (int[]) {999, 888};
  13. break;
  14. }
  15.  
  16. return items[0];
  17. }
  18. =================================================================
  19. ==17838==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fffffffdbc0 at pc 0x0000004013e5 bp 0x7fffffffdb50 sp 0x7fffffffdb48
  20. READ of size 4 at 0x7fffffffdbc0 thread T0
  21. #0 0x4013e4 in main /tmp/ubsan.c:15
  22. #1 0x7ffff73b8b7a in __libc_start_main ../csu/libc-start.c:308
  23. #2 0x4010a9 in _start (/tmp/a.out+0x4010a9)
  24.  
  25. Address 0x7fffffffdbc0 is located in stack of thread T0 at offset 64 in frame
  26. #0 0x401161 in main /tmp/ubsan.c:2
  27.  
  28. This frame has 3 object(s):
  29. [48, 52) '<unknown>'
  30. [64, 72) '<unknown>' <== Memory access at offset 64 is inside this variable
  31. [96, 108) '<unknown>'
  32. HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
  33. (longjmp and C++ exceptions *are* supported)
  34. SUMMARY: AddressSanitizer: stack-use-after-scope /tmp/ubsan.c:15 in main
  35. Shadow bytes around the buggy address:
  36. 0x10007fff7b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  37. 0x10007fff7b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  38. 0x10007fff7b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  39. 0x10007fff7b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  40. 0x10007fff7b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  41. =>0x10007fff7b70: f1 f1 f1 f1 f1 f1 f8 f2[f8]f2 f2 f2 00 04 f3 f3
  42. 0x10007fff7b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  43. 0x10007fff7b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  44. 0x10007fff7ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  45. 0x10007fff7bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  46. 0x10007fff7bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  47. Shadow byte legend (one shadow byte represents 8 application bytes):
  48. Addressable: 00
  49. Partially addressable: 01 02 03 04 05 06 07
  50. Heap left redzone: fa
  51. Freed heap region: fd
  52. Stack left redzone: f1
  53. Stack mid redzone: f2
  54. Stack right redzone: f3
  55. Stack after return: f5
  56. Stack use after scope: f8
  57. Global redzone: f9
  58. Global init order: f6
  59. Poisoned by user: f7
  60. Container overflow: fc
  61. Array cookie: ac
  62. Intra object redzone: bb
  63. ASan internal: fe
  64. Left alloca redzone: ca
  65. Right alloca redzone: cb
  66. Shadow gap: cc
  67. ==17838==ABORTING
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement