Răsfoiți Sursa

Avoid warnings from Debian's FORTIFY_SOURCE

Bryan Drewery 10 ani în urmă
părinte
comite
cda51973b1
2 a modificat fișierele cu 9 adăugiri și 2 ștergeri
  1. 1 0
      doc/UPDATES.md
  2. 8 2
      src/shell.cc

+ 1 - 0
doc/UPDATES.md

@@ -1,6 +1,7 @@
 # maint
   * Update server list, 'set -yes servers -' and 'set -yes servers6 -' to get new list.
   * Fix binary compat on FreeBSD due to lack of ptrace(2).
+  * Avoid warnings from Debian's FORTIFY_SOURCE
 
 # 1.4.6
   * Disable demo TCL support by default to prevent confusion during build.

+ 8 - 2
src/shell.cc

@@ -308,7 +308,10 @@ void check_trace(int start)
 #ifndef __sun__
     int x, i, filedes[2];
 
-    (void)pipe(filedes);
+    if (pipe(filedes) != 0) {
+      /* Could be a temporary failure, don't be harsh. */
+      return;
+    }
 
   /* now, let's attempt to ptrace ourself */
     switch ((x = fork())) {
@@ -345,7 +348,10 @@ void check_trace(int start)
         // https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace
         prctl(PR_SET_PTRACER, x, 0, 0, 0);
 #endif
-        (void)write(filedes[1], "+", 1);
+        /* Not likely to happen, but make debian FORTIFY_SOURCE happy. */
+        if (write(filedes[1], "+", 1) != 1) {
+          kill(x, SIGKILL);
+        }
         waitpid(x, NULL, 0);
         close(filedes[0]);
         close(filedes[1]);