Bug#1032514: unblock: quakespasm/0.95.1+dfsg-2
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock
X-Debbugs-Cc: quakespasm@packages.debian.org
Control: affects -1 + src:quakespasm
Please unblock package quakespasm
[ Reason ]
Fix #1032276
[ Impact ]
If not fixed, when the quake-server package is installed and quakespasm is
the selected alternative for quake-engine-server, the quake-server systemd
service spams the system log with rapid "Console input too long" messages.
[ Tests ]
Manual test: can configure /etc/alternatives/quake-engine-server =
/usr/games/quakespasm, systemctl restart quake-server.service, and connect
a client with `quake --engine=quakespasm '+connect 127.0.0.1'`. With the
version in bookworm, "Console input too long" messages appear until the
server is stopped. With the proposed version, those messages do not appear.
[ Risks ]
Low risk: almost a leaf package (one of multiple options for contrib
packages quake and quake-server), the patch is simple, and its small user
base is indicated by the fact that it has taken this long for anyone to
notice that the bug existed.
[ Checklist ]
[x] all changes are documented in the d/changelog
[x] I reviewed all changes and I approve them
[x] attach debdiff against the package in testing
unblock quakespasm/0.95.1+dfsg-2
diffstat for quakespasm-0.95.1+dfsg quakespasm-0.95.1+dfsg
Quake/sys_sdl_unix.c | 14 ++
debian/.gitignore | 5
debian/changelog | 9 +
debian/control | 2
debian/patches/series | 1
debian/patches/sys_sdl_unix-Stop-reading-from-stdin-when-EOF-is-reached.patch | 58 ++++++++++
6 files changed, 87 insertions(+), 2 deletions(-)
diff -Nru quakespasm-0.95.1+dfsg/debian/changelog quakespasm-0.95.1+dfsg/debian/changelog
--- quakespasm-0.95.1+dfsg/debian/changelog 2022-11-08 07:57:52.000000000 +0000
+++ quakespasm-0.95.1+dfsg/debian/changelog 2023-03-07 11:56:29.000000000 +0000
@@ -1,3 +1,12 @@
+quakespasm (0.95.1+dfsg-2) unstable; urgency=medium
+
+ * Add patch to fix running the server with /dev/null as stdin.
+ In particular, this makes it suitable for the systemd service in the
+ quake package. (Closes: #1032276)
+ * Standards-Version: 4.6.2 (no changes required)
+
+ -- Simon McVittie <smcv@debian.org> Tue, 07 Mar 2023 11:56:29 +0000
+
quakespasm (0.95.1+dfsg-1) unstable; urgency=medium
* New upstream release.
diff -Nru quakespasm-0.95.1+dfsg/debian/control quakespasm-0.95.1+dfsg/debian/control
--- quakespasm-0.95.1+dfsg/debian/control 2022-09-16 10:48:48.000000000 +0100
+++ quakespasm-0.95.1+dfsg/debian/control 2023-03-07 11:56:29.000000000 +0000
@@ -13,7 +13,7 @@
libsdl2-dev,
libvorbis-dev
Rules-Requires-Root: no
-Standards-Version: 4.6.1
+Standards-Version: 4.6.2
Vcs-Browser: https://salsa.debian.org/games-team/quakespasm
Vcs-Git: https://salsa.debian.org/games-team/quakespasm.git
Homepage: http://quakespasm.sourceforge.net/
diff -Nru quakespasm-0.95.1+dfsg/debian/.gitignore quakespasm-0.95.1+dfsg/debian/.gitignore
--- quakespasm-0.95.1+dfsg/debian/.gitignore 1970-01-01 01:00:00.000000000 +0100
+++ quakespasm-0.95.1+dfsg/debian/.gitignore 2023-03-07 11:56:29.000000000 +0000
@@ -0,0 +1,5 @@
+/*.debhelper.log
+/*.substvars
+/files
+/quakespasm/
+/quakespasm-dbg/
diff -Nru quakespasm-0.95.1+dfsg/debian/patches/series quakespasm-0.95.1+dfsg/debian/patches/series
--- quakespasm-0.95.1+dfsg/debian/patches/series 2022-09-16 10:48:48.000000000 +0100
+++ quakespasm-0.95.1+dfsg/debian/patches/series 2023-03-07 11:56:29.000000000 +0000
@@ -4,3 +4,4 @@
mkpak-bashism.patch
reproducible-build.patch
rotfish-double-count.patch
+sys_sdl_unix-Stop-reading-from-stdin-when-EOF-is-reached.patch
diff -Nru quakespasm-0.95.1+dfsg/debian/patches/sys_sdl_unix-Stop-reading-from-stdin-when-EOF-is-reached.patch quakespasm-0.95.1+dfsg/debian/patches/sys_sdl_unix-Stop-reading-from-stdin-when-EOF-is-reached.patch
--- quakespasm-0.95.1+dfsg/debian/patches/sys_sdl_unix-Stop-reading-from-stdin-when-EOF-is-reached.patch 1970-01-01 01:00:00.000000000 +0100
+++ quakespasm-0.95.1+dfsg/debian/patches/sys_sdl_unix-Stop-reading-from-stdin-when-EOF-is-reached.patch 2023-03-07 11:56:29.000000000 +0000
@@ -0,0 +1,58 @@
+From: Simon McVittie <smcv@debian.org>
+Date: Tue, 7 Mar 2023 11:46:00 +0000
+Subject: sys_sdl_unix: Stop reading from stdin when EOF is reached
+
+If the quakespasm server is run noninteractively with stdin redirected
+from /dev/null (for example as a systemd service), this loop would
+previously ignore EOF (read() returns 0) and append the uninitialized
+contents of `c` to the buffer once per iteration, until the buffer is
+full, at which point it would log "Console input too long!" and repeat.
+
+For completeness, treat read errors (read() returns -1) as equivalent
+to EOF.
+
+Bug: https://sourceforge.net/p/quakespasm/bugs/59/
+Bug-Debian: https://bugs.debian.org/1032276
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ Quake/sys_sdl_unix.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c
+index 8820dc5..061e946 100644
+--- a/Quake/sys_sdl_unix.c
++++ b/Quake/sys_sdl_unix.c
+@@ -417,20 +417,32 @@ double Sys_DoubleTime (void)
+
+ const char *Sys_ConsoleInput (void)
+ {
++ static qboolean con_eof = false;
+ static char con_text[256];
+ static int textlen;
+ char c;
+ fd_set set;
+ struct timeval timeout;
++ ssize_t n;
+
+ FD_ZERO (&set);
+ FD_SET (0, &set); // stdin
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
++ if (con_eof)
++ return NULL;
++
+ while (select (1, &set, NULL, NULL, &timeout))
+ {
+- read (0, &c, 1);
++ n = read (0, &c, 1);
++ if (n <= 0)
++ {
++ // Finish processing whatever is already in the
++ // buffer (if anything), then stop reading
++ con_eof = true;
++ c = '\n';
++ }
+ if (c == '\n' || c == '\r')
+ {
+ con_text[textlen] = '\0';
diff -Nru quakespasm-0.95.1+dfsg/Quake/sys_sdl_unix.c quakespasm-0.95.1+dfsg/Quake/sys_sdl_unix.c
--- quakespasm-0.95.1+dfsg/Quake/sys_sdl_unix.c 2022-10-25 08:35:20.000000000 +0100
+++ quakespasm-0.95.1+dfsg/Quake/sys_sdl_unix.c 2023-03-07 12:10:32.000000000 +0000
@@ -417,20 +417,32 @@
const char *Sys_ConsoleInput (void)
{
+ static qboolean con_eof = false;
static char con_text[256];
static int textlen;
char c;
fd_set set;
struct timeval timeout;
+ ssize_t n;
FD_ZERO (&set);
FD_SET (0, &set); // stdin
timeout.tv_sec = 0;
timeout.tv_usec = 0;
+ if (con_eof)
+ return NULL;
+
while (select (1, &set, NULL, NULL, &timeout))
{
- read (0, &c, 1);
+ n = read (0, &c, 1);
+ if (n <= 0)
+ {
+ // Finish processing whatever is already in the
+ // buffer (if anything), then stop reading
+ con_eof = true;
+ c = '\n';
+ }
if (c == '\n' || c == '\r')
{
con_text[textlen] = '\0';
Reply to: