Fix pipe fds leak in copyInternalSpliceSocket
This method used a temporarily pipe to copy data but forget to close it
before exiting, which will cause fd leak. As the number of times this
method is called increases, the process may abort since the fd reaches
its limit. So close the pipe before exiting.
Bug: 344767008
Change-Id: I2028bf2e36e9dde9b6aaea1f7c758169e6842cc7
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 4dc32d5..f3d743d 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -580,6 +580,8 @@
", copied:" + progress +
", read:" + (count - countToRead) +
", in pipe: " + countInPipe);
+ Os.close(pipes[0]);
+ Os.close(pipes[1]);
throw new ErrnoException("splice, pipe --> fdOut", EIO);
} else {
progress += t;
@@ -607,6 +609,8 @@
listener.onProgress(progressSnapshot);
});
}
+ Os.close(pipes[0]);
+ Os.close(pipes[1]);
return progress;
}