Package: psmisc
Version: 22.21-2.1+b2
Severity: normal
Dear Maintainer,
When I run pstree on my busy servers, it usually SIGSEGVs before outputting
anything.
This is because pstree is calling `fclose(f)` on an `f` that may
be null, which is not permitted:
The behaviour of fclose() is undefined if the stream parameter is
an illegal pointer, or is a descriptor already
passed to a previous invocation of fclose().
(quoting man fclose)
-- System Information:
Debian Release: 9.7
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.9.0-8-amd64 (SMP w/64 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8),
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages psmisc depends on:
ii libc6 2.24-11+deb9u3
ii libselinux1 2.6-3+b3
ii libtinfo5 6.0+20161126-1+deb9u2
psmisc recommends no packages.
psmisc suggests no packages.
-- no debconf information
diff -ur psmisc-22.21/src/pstree.c psmisc-22.21-fixed/src/pstree.c
--- psmisc-22.21/src/pstree.c 2014-02-02 05:59:07.000000000 +0000
+++ psmisc-22.21-fixed/src/pstree.c 2019-02-27 23:19:40.611866628 +0000
@@ -819,7 +819,9 @@
}
/* Fall back to old method */
sprintf(threadname, "{%.*s}", COMM_LEN, comm);
- fclose(file);
+ if (file) {
+ fclose(file);
+ }
return threadname;
}