CVSROOT:        /cvs
Module name:    src
Changes by:     k...@cvs.openbsd.org    2020/07/04 05:23:35

Modified files:
        usr.bin/ftp    : fetch.c 

Log message:
Avoid malloc(3) calls in signal handler

Fetch aborts through SIGINT (^C) print a message with fputs(3), but this
calls malloc() on its own, which is not supported from interrupt handler
context.

Fix it by using write(2) which avoids further memory allocations.
While here, merge abortfile() into the identical aborthttp() with a more
generic "fetch aborted." message for simplicity.

Spotted with vm.malloc_conf=SU and ^C on a port's "make fetch" causing

ftp(49660) in malloc(): recursive call
Abort trap (core dumped)

OK jca (who came up with using write(2) independently)

Reply via email to