Package: netperf
Version: 2.7.0-0.2
Severity: critical
Tags: patch upstream
Justification: breaks unrelated software
X-Debbugs-Cc: [email protected]
This bug is hard to reproduce, as the condition that lead to
Netserver deleting /dev/null are quite mysterious. I was getting my
/dev/null removed over the years at very rare occurences, until
I managed to track it down to Netserver.
The issue is not present in the tarball for version 2.7.0. It
was introduced in patch :
02018-02-07T17:21:57-08:00~5380b1f.patch
In particular, this line :
+ FileName = NETPERF_NULL;
This patch is part of the Netperf GitHub, which is why I added
the upstream tag.
I will report this bug upstream, unfortunately I don't expect
much action :-(
A quick look at the source code show that the code is wrong in
very obvious way. The fix is quite simple and obvious, and I provide
a patch (included below).
Note that my patch replace
11_no_change_perms_on_dev-null.patch, so please remove that patch
before applying mine.
Thanks in advance !
Jean
-- System Information:
Debian Release: 11.9
APT prefers oldstable-security
APT policy: (500, 'oldstable-security'), (500, 'oldstable-proposed-updates'),
(500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.10.0-28-amd64 (SMP w/12 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND,
TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages netperf depends on:
ii libc6 2.31-13+deb11u8
netperf recommends no packages.
netperf suggests no packages.
-- no debconf information
diff --git a/src/netserver.c b/src/netserver.c
index 2e6b567..ae4ad61 100644
--- a/src/netserver.c
+++ b/src/netserver.c
@@ -220,7 +220,7 @@ unlink_empty_debug_file() {
#if !defined(WIN32)
struct stat buf;
- if (stat(FileName,&buf)== 0) {
+ if ( (! suppress_debug) && (stat(FileName,&buf)== 0) ) {
if (buf.st_size == 0)
unlink(FileName);
@@ -239,6 +239,7 @@ open_debug_file()
if (where != NULL) fflush(where);
if (suppress_debug) {
strncpy(FileName, NETPERF_NULL, sizeof(FileName));
+ FileName[sizeof(FileName) - 1] = '\0';
where = fopen(FileName, "w");
} else {
int fd;
@@ -260,7 +261,8 @@ open_debug_file()
#if !defined(WIN32)
- chmod(FileName,0644);
+ if (! suppress_debug)
+ chmod(FileName,0644);
/* redirect stdin to "/dev/null" */
rd_null_fp = fopen(NETPERF_NULL,"r");
diff --git a/src/netserver.c b/src/netserver.c
index 2e6b567..ae4ad61 100644
--- a/src/netserver.c
+++ b/src/netserver.c
@@ -220,7 +220,7 @@ unlink_empty_debug_file() {
#if !defined(WIN32)
struct stat buf;
- if (stat(FileName,&buf)== 0) {
+ if ( (! suppress_debug) && (stat(FileName,&buf)== 0) ) {
if (buf.st_size == 0)
unlink(FileName);
@@ -239,6 +239,7 @@ open_debug_file()
if (where != NULL) fflush(where);
if (suppress_debug) {
strncpy(FileName, NETPERF_NULL, sizeof(FileName));
+ FileName[sizeof(FileName) - 1] = '\0';
where = fopen(FileName, "w");
} else {
int fd;
@@ -260,7 +261,8 @@ open_debug_file()
#if !defined(WIN32)
- chmod(FileName,0644);
+ if (! suppress_debug)
+ chmod(FileName,0644);
/* redirect stdin to "/dev/null" */
rd_null_fp = fopen(NETPERF_NULL,"r");
diff --git a/src/netserver.c b/src/netserver.c
index 2e6b567..ae4ad61 100644
--- a/src/netserver.c
+++ b/src/netserver.c
@@ -220,7 +220,7 @@ unlink_empty_debug_file() {
#if !defined(WIN32)
struct stat buf;
- if (stat(FileName,&buf)== 0) {
+ if ( (! suppress_debug) && (stat(FileName,&buf)== 0) ) {
if (buf.st_size == 0)
unlink(FileName);
@@ -239,6 +239,7 @@ open_debug_file()
if (where != NULL) fflush(where);
if (suppress_debug) {
strncpy(FileName, NETPERF_NULL, sizeof(FileName));
+ FileName[sizeof(FileName) - 1] = '\0';
where = fopen(FileName, "w");
} else {
int fd;
@@ -260,7 +261,8 @@ open_debug_file()
#if !defined(WIN32)
- chmod(FileName,0644);
+ if (! suppress_debug)
+ chmod(FileName,0644);
/* redirect stdin to "/dev/null" */
rd_null_fp = fopen(NETPERF_NULL,"r");