Skip to content

Conversation

@piotrkochan
Copy link

PhotoRec often corrupted the terminal when killed with Ctrl+C in ncurses mode. Users had to run reset or stty sane to restore normal terminal functionality after interrupting the program. This PR fixes that.

@cgsecurity
Copy link
Owner

All functions called by end_ncurses() may not be signal-safe but it seems to work without side effect under Linux Fedora 41 with this shorted patch:

--- /home/kmaster/src/git/testdisk/src/phmain.c 2023-02-19 08:04:54.627483562 +0100
+++ ./phmain.c 2025-09-28 14:11:26.295956987 +0200
@@ -112,6 +112,9 @@
log_flush();
if(need_to_stop==1)
{
+#ifdef HAVE_NCURSES

  • end_ncurses();
    +#endif
    action.sa_handler=SIG_DFL;
    sigaction(sig,&action,NULL);
    kill(0, sig);

src/testdisk.c will need to get a similar patch.
Under which OS have you tested this patch ?

@piotrkochan
Copy link
Author

@cgsecurity

piotr@pjoter:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble
piotr@pjoter:~$ echo $SHELL
/bin/bash

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.

2 participants