Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create unit tests for the programming contest-only functionality #1

Open
lhchavez opened this issue Jul 24, 2014 · 1 comment
Open
Assignees

Comments

@lhchavez
Copy link
Member

No description provided.

@lhchavez lhchavez self-assigned this Jul 24, 2014
@joemmanuel
Copy link
Member

yay! 1st issue :P

lhchavez added a commit that referenced this issue Sep 2, 2017
This change fixes the following buffer overflow in system_unittest,
found by running `make tests` with AddressSanitizer:

==30977==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffddc9c3055 at pc 0x7ff7ec00f2d5 bp 0x7ffddc9c2ca0 sp 0x7ffddc9c2448
READ of size 6 at 0x7ffddc9c3055 thread T0
    #0 0x7ff7ec00f2d4  (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x472d4)
    #1 0x44fa17 in write_pid_to_path_basic_Test::TestBody() system_unittest.cc:132

Address 0x7ffddc9c3055 is located in stack of thread T0 at offset 805 in frame
    #0 0x44ef6f in write_pid_to_path_basic_Test::TestBody() system_unittest.cc:121

  This frame has 7 object(s):
    [32, 40) 'path'
    [96, 104) 'fp'
    [160, 176) 'gtest_ar'
    [224, 256) '<unknown>'
    [288, 320) '<unknown>'
    [352, 744) 'ss'
    [800, 805) 'data' <== Memory access at offset 805 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow ??:0 ??
Shadow bytes around the buggy address:
  0x10003b9305b0: f2 f2 00 f4 f4 f4 f2 f2 f2 f2 00 00 f4 f4 f2 f2
  0x10003b9305c0: f2 f2 00 00 00 00 f2 f2 f2 f2 00 00 00 00 f2 f2
  0x10003b9305d0: f2 f2 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10003b9305e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10003b9305f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10003b930600: 00 00 00 f4 f4 f4 f2 f2 f2 f2[05]f4 f4 f4 f3 f3
  0x10003b930610: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10003b930620: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x10003b930630: 00 00 f4 f4 f3 f3 f3 f3 00 00 00 00 00 00 00 00
  0x10003b930640: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x10003b930650: 00 00 f4 f4 f3 f3 f3 f3 00 00 00 00 00 00 00 00
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
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  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
==30977==ABORTING

Bug: None
Test: make tests (with -fsanitize=address in {C,CXX}FLAGS).
Change-Id: If5145d60f34664c39b560bf5a739bdac7ee689b6
lhchavez added a commit that referenced this issue Sep 2, 2017
This change frees the |struct minijail| in minijail0:

=================================================================
==31408==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 768 byte(s) in 1 object(s) allocated from:
    #0 0x7f69b789f79a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
    #1 0x4030cb in main minijail0.c:592
    #2 0x7fffe06c1724  (<unknown module>)

SUMMARY: AddressSanitizer: 768 byte(s) leaked in 1 allocation(s).

Bug: None
Test: ./minijail0 (compiled with -fsanitize=address)
Change-Id: If01e1174b736f6d19abe3597318bed4dc3fb013a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants