File: 12_no_chmod_unlink_dev-null.diff

package info (click to toggle)
netperf 2.7.0%2Bgit20210121.3bc455b%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,740 kB
  • sloc: ansic: 41,885; sh: 5,265; xml: 3,129; python: 2,480; makefile: 70; awk: 68
file content (31 lines) | stat: -rw-r--r-- 842 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
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");