Skip to content

Conversation

@nloomans
Copy link
Owner

@nloomans nloomans commented Mar 9, 2020

@lgutter made the following change to libft

made memset significantly faster for very long strings.

Memory will now be set in chunks of the size of an unsigned long long,
until there are less characters left than the chunk size.

lgutter and others added 2 commits March 9, 2020 16:59
Memory will now be set in chunks of the size of an unsigned long long,
until there are less characters left than the chunk size.
nloomans added a commit that referenced this pull request Jul 27, 2020
This can be reproduced by pressing control + z.

    TOSH $ ../src/input/run_next_action.c:70:30: runtime error: index 90 out of bounds for type 't_normal_action *[89]'
    ../src/input/run_next_action.c:70:30: runtime error: load of address 0x55d5013e5950 with insufficient space for an object of type 't_normal_action *'
    0x55d5013e5950: note: pointer points here
     00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                  ^
    =================================================================
    ==95697==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55d5013e5950 at pc 0x55d50136705a bp 0x7ffc5a96c940 sp 0x7ffc5a96c930
    READ of size 8 at 0x55d5013e5950 thread T0
        #0 0x55d501367059 in run_next_keypress ../src/input/run_next_action.c:70
        #1 0x55d501367851 in input__run_next_action ../src/input/run_next_action.c:103
        #2 0x55d501364d42 in event_loop ../src/input/read.c:40
        #3 0x55d5013658ba in input_read ../src/input/read.c:85
        #4 0x55d50134ac66 in tosh ../src/bootstrap/tosh.c:84
        #5 0x55d501370a09 in main ../src/bootstrap/main.c:49
        #6 0x7f6c04d49001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
        #7 0x55d50134a46d in _start (/home/cyborg/archive/42/tosh/build/tosh+0x4946d)

    0x55d5013e5950 is located 8 bytes to the right of global variable 'g_action_control_table' defined in '../src/input/run_next_action.c:47:18' (0x55d5013e5680) of size 712
    0x55d5013e5950 is located 48 bytes to the left of global variable '*.Lubsan_data0' defined in '../src/input/run_next_action.c' (0x55d5013e5980) of size 32
    SUMMARY: AddressSanitizer: global-buffer-overflow ../src/input/run_next_action.c:70 in run_next_keypress
    Shadow bytes around the buggy address:
      0x0abb20274ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x0abb20274ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x0abb20274af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x0abb20274b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x0abb20274b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    =>0x0abb20274b20: 00 00 00 00 00 00 00 00 00 f9[f9]f9 f9 f9 f9 f9
      0x0abb20274b30: 00 00 00 00 f9 f9 f9 f9 00 00 f9 f9 f9 f9 f9 f9
      0x0abb20274b40: 00 00 00 00 f9 f9 f9 f9 00 00 f9 f9 f9 f9 f9 f9
      0x0abb20274b50: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9
      0x0abb20274b60: 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9
      0x0abb20274b70: 00 00 00 00 f9 f9 f9 f9 00 00 f9 f9 f9 f9 f9 f9
    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
      Shadow gap:              cc
    ==95697==ABORTING
nloomans added a commit that referenced this pull request Jul 28, 2020
TOSH $ >foo.txt
../src/exec/quote_and_expansion/replacer_fsm.c:126:44: runtime error: load of null pointer of type 'char'
AddressSanitizer:DEADLYSIGNAL
=================================================================
==102705==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x561b57993352 bp 0x7ffe87989710 sp 0x7ffe87988de0 T0)
==102705==The signal is caused by a READ memory access.
==102705==Hint: address points to the zero page.
    #0 0x561b57993352 in replacer_fsm ../src/exec/quote_and_expansion/replacer_fsm.c:126
    #1 0x561b5799489d in quote_and_expansion ../src/exec/quote_and_expansion/quote_and_expansion.c:82
    #2 0x561b579892ee in exec_run ../src/exec/run.c:32
    #3 0x561b5798392f in run_command ../src/bootstrap/tosh.c:48
    #4 0x561b57983de0 in tosh ../src/bootstrap/tosh.c:93
    #5 0x561b579a99f4 in main ../src/bootstrap/main.c:49
    #6 0x7fd30e722001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
    #7 0x561b5798346d in _start (/home/cyborg/archive/42/tosh/build/tosh+0x4946d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../src/exec/quote_and_expansion/replacer_fsm.c:126 in replacer_fsm
==102705==ABORTING
nloomans added a commit that referenced this pull request Jul 29, 2020
    TOSH $ cat <<EOF
    > EOF
    ../src/exec/quote_and_expansion/replacer_fsm.c:98:32: runtime error: load of null pointer of type 'const char'
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==184961==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x5633fa0e5ca3 bp 0x7fff4aaeaeb0 sp 0x7fff4aaeada0 T0)
    ==184961==The signal is caused by a READ memory access.
    ==184961==Hint: address points to the zero page.
        #0 0x5633fa0e5ca3 in iter_fsm ../src/exec/quote_and_expansion/replacer_fsm.c:98
        #1 0x5633fa0e670c in replacer_fsm ../src/exec/quote_and_expansion/replacer_fsm.c:134
        #2 0x5633fa0e3574 in acquire_heredoc ../src/exec/redirect/redirect_heredoc.c:75
        #3 0x5633fa0e3856 in redirect_heredoc ../src/exec/redirect/redirect_heredoc.c:89
        #4 0x5633fa0dfb65 in redirect ../src/exec/redirect/handle_redirections.c:48
        #5 0x5633fa0e0650 in exec__handle_redirections ../src/exec/redirect/handle_redirections.c:113
        #6 0x5633fa0de6ee in exec__set_arguments ../src/exec/set_arguments.c:74
        #7 0x5633fa0df0d2 in exec__single ../src/exec/single.c:53
        #8 0x5633fa0dc6b3 in exec_run ../src/exec/run.c:40
        #9 0x5633fa0d692f in run_command ../src/bootstrap/tosh.c:48
        #10 0x5633fa0d6de0 in tosh ../src/bootstrap/tosh.c:93
        #11 0x5633fa0fc9f4 in main ../src/bootstrap/main.c:49
        #12 0x7f4475949001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
        #13 0x5633fa0d646d in _start (/home/cyborg/archive/42/tosh/build/tosh+0x4946d)

    AddressSanitizer can not provide additional info.
    SUMMARY: AddressSanitizer: SEGV ../src/exec/quote_and_expansion/replacer_fsm.c:98 in iter_fsm
    ==184961==ABORTING
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.

3 participants