Package: unzip
Version: 6.0-31
Severity: minor
Tags: patch

When unzip is interrupted with Ctrl+C at an interactive replacement prompt, the 
shell prompt appears on the same line as ^C.

Steps to reproduce:

1. Create a file and archive it:

   tmpdir=$(mktemp -d)
   cd "$tmpdir"
   printf 'hello\n' > file.txt
   zip -q sample.zip file.txt

2. Run:

   unzip sample.zip

3. Press Ctrl+C at the replacement prompt.

The current output is:

replace file.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: ^Cuser@host:~$

The expected output is:

replace file.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: ^C
user@host:~$

The signal handler in fileio.c already contains code intended to add a newline. 
However, its compile-time condition excludes that code on systems defining 
SIGBUS or SIGSEGV, including Linux, regardless of the signal actually received.

The attached patch preserves the existing behavior on other systems and adds a 
runtime SIGINT branch when the original condition suppresses the newline.

The problem was originally reproduced with Ubuntu's unzip 6.0-29ubuntu1. I 
confirmed that the affected code is present in Debian's 6.0-31 source package.

Testing performed:

* Built successfully using the complete Debian patch series.
* Built the binary Debian package successfully with dpkg-buildpackage.
* Debian-profile Lintian completed with exit code 0.
* Confirmed that the shell prompt starts on a new line after Ctrl+C.
* Confirmed that the exit code remains 80.



-- System Information:
Debian Release: forky/sid
  APT prefers resolute-updates
  APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 
'resolute'), (100, 'resolute-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 7.0.0-28-generic (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE, 
TAINT_SOFTLOCKUP
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Description: Print a newline when SIGINT interrupts an interactive prompt
 The compile-time condition suppresses the newline on systems defining
 SIGBUS or SIGSEGV, including Linux. Preserve the existing behavior on
 other systems and add the missing newline when SIGINT is received.
Author: Adn Ehab Elkawass <[email protected]>
Forwarded: no
Last-Update: 2026-08-14

diff --git a/fileio.c b/fileio.c
index ba0a1d0..aa3117d 100644
--- a/fileio.c
+++ b/fileio.c
@@ -1637,3 +1637,6 @@ void handler(signal)   /* upon interrupt, turn on echo 
and exit cleanly */
 #if !(defined(SIGBUS) || defined(SIGSEGV))      /* add a newline if not at */
     (*G.message)((zvoid *)&G, slide, 0L, 0x41); /*  start of line (to stderr; 
*/
+#elif defined(SIGINT)
+    if (signal == SIGINT)
+        (*G.message)((zvoid *)&G, slide, 0L, 0x41);
 #endif                                          /*  slide[] should be safe) */

Reply via email to