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

Fix strcpy and strncpy tests #24

Merged
merged 2 commits into from
Mar 18, 2024
Merged

Fix strcpy and strncpy tests #24

merged 2 commits into from
Mar 18, 2024

Conversation

thejpster
Copy link
Member

Closes: #22

@thejpster thejpster changed the title Fix strcmp and strncmp tests Fix strcpy and strncpy tests Mar 17, 2024
@thejpster
Copy link
Member Author

Before you would get this error. I removed the offending test, as the other test was sufficient.

RUSTFLAGS=-Zsanitizer=address cargo +nightly test -Zbuild-std --target=x86_64-unknown-linux-gnu -- two
    Finished `test` profile [unoptimized + debuginfo] target(s) in 3.11s
     Running unittests src/lib.rs (target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9)

running 2 tests
=================================================================
==2606==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fc42c8ffb92 at pc 0x55584f21a7cc bp 0x7fc42d3fd9f0 sp 0x7fc42d3fd9e8
WRITE of size 1 at 0x7fc42c8ffb92 thread T1
    #0 0x55584f21a7cb  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f07cb) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #1 0x55584f21e5e4  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f45e4) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #2 0x55584f21a936  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f0936) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #3 0x55584f21f155  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f5155) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #4 0x55584f265341  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x23b341) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #5 0x55584f239e24  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x20fe24) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #6 0x55584f300d0a  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x2d6d0a) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #7 0x55584f23b1a2  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x2111a2) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #8 0x55584f262f22  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x238f22) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #9 0x55584f36b76e  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x34176e) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #10 0x55584f3825aa  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x3585aa) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #11 0x55584f36a9ee  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x3409ee) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #12 0x55584f2c5bdd  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x29bbdd) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #13 0x55584f23a7d1  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x2107d1) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #14 0x55584f2392e4  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x20f2e4) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #15 0x55584f239a9f  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x20fa9f) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #16 0x55584f2e924d  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x2bf24d) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #17 0x55584f22528a  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1fb28a) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #18 0x55584f262ffe  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x238ffe) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #19 0x55584f36b856  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x341856) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #20 0x55584f3825aa  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x3585aa) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #21 0x55584f36ac5b  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x340c5b) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #22 0x55584f2c5c2d  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x29bc2d) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #23 0x55584f224d41  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1fad41) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #24 0x55584f263b3e  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x239b3e) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #25 0x55584f407ee8  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x3ddee8) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #26 0x55584f407cd6  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x3ddcd6) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #27 0x55584f488623  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x45e623) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #28 0x55584f1e09a8  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1b69a8) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #29 0x7fc430379133  (/lib/x86_64-linux-gnu/libc.so.6+0x89133) (BuildId: 82ce4e6e4ef08fa58a3535f7437bd3e592db5ac0)
    #30 0x7fc4303f97db  (/lib/x86_64-linux-gnu/libc.so.6+0x1097db) (BuildId: 82ce4e6e4ef08fa58a3535f7437bd3e592db5ac0)

Address 0x7fc42c8ffb92 is located in stack of thread T1 at offset 146 in frame
    #0 0x55584f21e4af  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f44af) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)

  This frame has 3 object(s):
    [32, 80) '_17' (line 43)
    [112, 128) '_11' (line 43)
    [144, 146) 'dest' (line 41) <== Memory access at offset 146 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
Thread T1 created by T0 here:
    #0 0x55584f1c8a81  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x19ea81) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #1 0x55584f487ec8  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x45dec8) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #2 0x55584f224321  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1fa321) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #3 0x55584f2238ef  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f98ef) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #4 0x55584f2252a6  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1fb2a6) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #5 0x55584f233a57  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x209a57) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #6 0x55584f2e69f9  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x2bc9f9) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #7 0x55584f22e5ee  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x2045ee) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #8 0x55584f22f50e  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x20550e) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #9 0x55584f215322  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1eb322) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #10 0x55584f480e3a  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x456e3a) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #11 0x55584f58ed71  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x564d71) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #12 0x55584f480e8a  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x456e8a) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #13 0x55584f21a0f8  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f00f8) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
    #14 0x55584f21534d  (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1eb34d) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)

SUMMARY: AddressSanitizer: stack-buffer-overflow (/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9+0x1f07cb) (BuildId: 897af6e5613d60997c98b906db9f98fb8a8ec8f3)
Shadow bytes around the buggy address:
  0x7fc42c8ff900: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x7fc42c8ff980: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
  0x7fc42c8ffa00: f1 f1 f1 f1 00 00 00 f2 f2 f2 f2 f2 00 00 00 f3
  0x7fc42c8ffa80: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fc42c8ffb00: f1 f1 f1 f1 f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 f8 f8
=>0x7fc42c8ffb80: f2 f2[02]f3 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fc42c8ffc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fc42c8ffc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fc42c8ffd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fc42c8ffd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7fc42c8ffe00: 00 00 00 00 00 00 00 00 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
  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
==2606==ABORTING
error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `/mnt/c/Users/msn/LDocuments/tinyrlibc/target/x86_64-unknown-linux-gnu/debug/deps/tinyrlibc-02d9dbac8e91f4d9 two` (exit status: 1)
note: test exited abnormally; to see the full output pass --nocapture to the harness.

Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@eldruin eldruin added this pull request to the merge queue Mar 18, 2024
Merged via the queue into master with commit 83ae4a9 Mar 18, 2024
14 checks passed
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

Successfully merging this pull request may close these issues.

stack-buffer-overflow in strcpy::test::two
2 participants