File: 12_no_chmod_unlink_dev-null.diff

package info (click to toggle)
netperf 2.7.0%2Bgit20210121.3bc455b%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,784 kB
  • sloc: ansic: 41,887; sh: 5,277; xml: 3,129; python: 2,480; makefile: 70; awk: 68
file content (39 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From: netperf Debian Maintainers <netperf@packages.debian.org>
Date: Tue, 9 Sep 2025 13:32:13 +0200
Subject: _no_chmod_unlink_dev-null

---
 src/netserver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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");