cc693243 — Gabor Koszegi 11 days ago
Correct tee SIGINT test
tests: make echo tests robust to build directory
env: fix potential NULL pointer dereference

The two points where the elements of environ are accessed need to be
guarded with a NULL check. env can segfault otherwise.
599fbbb9 — Gabor Koszegi 21 days ago
Implement tee
.build.yml: disable ASAN

Not available for Alpine Linux (or musl libc?)
ctools(7): add echo(1)
Implement echo

The behaviour of echo command is to print exactly as the arguments are,
unless -n is in which the escape chars are recognized.
Implement nohup
Enable -Werror for zero warning build
Enable ASAN on ci tests
chown/chgrp: Fix memory leak

$ meson test -C build --verbose chown
ninja: Entering directory `/home/rumpelsepp/Projects/vendor/ctools/build'
ninja: no work to do.
should_handle_simple          OK
should_handle_several         OK
should_handle_mutex_options   OK
should_handle_recursive
=================================================================
==65006==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 65632 byte(s) in 2 object(s) allocated from:
    #0 0x7f2a9b3f9ada in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f2a9a88160a in __alloc_dir (/usr/lib/libc.so.6+0xc460a)

SUMMARY: AddressSanitizer: 65632 byte(s) leaked in 2 allocation(s).
FAIL
should_handle_recursive_Hflag
=================================================================
==65054==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 65632 byte(s) in 2 object(s) allocated from:
    #0 0x7f4cd631fada in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f4cd57a760a in __alloc_dir (/usr/lib/libc.so.6+0xc460a)

SUMMARY: AddressSanitizer: 65632 byte(s) leaked in 2 allocation(s).
FAIL
should_handle_recursive_Lflag
=================================================================
==65102==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 131264 byte(s) in 4 object(s) allocated from:
    #0 0x7f7dd8029ada in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f7dd74b160a in __alloc_dir (/usr/lib/libc.so.6+0xc460a)

SUMMARY: AddressSanitizer: 131264 byte(s) leaked in 4 allocation(s).
FAIL
should_handle_recursive_Pflag
=================================================================
==65150==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32816 byte(s) in 1 object(s) allocated from:
    #0 0x7f7914ad4ada in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f7913f5c60a in __alloc_dir (/usr/lib/libc.so.6+0xc460a)

SUMMARY: AddressSanitizer: 32816 byte(s) leaked in 1 allocation(s).
FAIL
should_handle_owner_change    SKIP($ESCALATE undefined)
OK
Passed: 4 tests
Failed: 4 tests
1/1 chown                                   FAIL     0.92 s (exit status 1)
cat: Fix stack use after scope

$ meson test -C build --verbose cat
ninja: Entering directory `/home/rumpelsepp/Projects/vendor/ctools/build'
[4/4] Linking target head.
should_handle_ddash     OK
should_handle_one_file  OK
should_handle_two_files OK
should_handle_stdin     =================================================================
==400903==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffeef650a60 at pc 0x55ea6a4fc991 bp 0x7ffeef650a10 sp 0x7ffeef650a00
READ of size 8 at 0x7ffeef650a60 thread T0
    #0 0x55ea6a4fc990 in main ../src/cat.c:77
    #1 0x7fb4f253bee2 in __libc_start_main (/usr/lib/libc.so.6+0x26ee2)
    #2 0x55ea6a4fc1dd in _start (/home/rumpelsepp/Projects/vendor/ctools/build/cat+0x21dd)

Address 0x7ffeef650a60 is located in stack of thread T0 at offset 32 in frame
    #0 0x55ea6a4fc6de in main ../src/cat.c:53

  This frame has 1 object(s):
    [32, 40) '<unknown>' <== Memory access at offset 32 is inside 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)
SUMMARY: AddressSanitizer: stack-use-after-scope ../src/cat.c:77 in main
Shadow bytes around the buggy address:
  0x10005dec20f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10005dec2140: 00 00 00 00 00 00 00 00 f1 f1 f1 f1[f8]f3 f3 f3
  0x10005dec2150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005dec2190: 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
  Shadow gap:              cc
==400903==ABORTING
FAIL
should_handle_u_flag    FAIL
Passed: 3 tests
Failed: 2 tests
1/1 cat                                     FAIL     0.12 s (exit status 1)

Ok:                    0
Expected Fail:         0
Fail:                  1
Unexpected Pass:       0
Skipped:               0
Timeout:               0
head: Unify error path and fix memory leak

$ meson test -C build --verbose  head
ninja: Entering directory `/home/rumpelsepp/Projects/vendor/ctools/build'
ninja: no work to do.
should_read_from_stdin
=================================================================
==399092==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8192 byte(s) in 1 object(s) allocated from:
    #0 0x7f28f131ece8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153
    #1 0x55a9faa60582 in head ../src/head.c:32
    #2 0x55a9faa60ae9 in main ../src/head.c:82
    #3 0x7f28f0708ee2 in __libc_start_main (/usr/lib/libc.so.6+0x26ee2)

SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 1 allocation(s).
FAIL
sleep: improve docs
Implement sleep
ccc1d877 — Christopher Vittal a month ago
Implement env
16cab053 — Christopher Vittal a month ago
Make test scripts POSIX compliant

"." with argument is not POSIX compliant, so it must be removed.
Instead, set tool directly in the test scripts.
0e9f63c4 — Christopher Vittal 2 months ago
Add dirname
Implement rmdir
Next