summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author hangl <quic_hangl@quicinc.com> 2024-06-04 17:58:31 +0800
committer hangl <quic_hangl@quicinc.com> 2024-06-04 18:08:47 +0800
commitdf29b7fe3ac149674027b61ee3664bdc8a3af1c7 (patch)
tree72a149e036006cc112170244cc74505cfa6bf759
parent921b174898d0dbf83f556d34d48d2646036f637f (diff)
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
-rw-r--r--core/java/android/os/FileUtils.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index 4dc32d5039b6..f3d743d51e4a 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -580,6 +580,8 @@ public final class FileUtils {
", 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 @@ public final class FileUtils {
listener.onProgress(progressSnapshot);
});
}
+ Os.close(pipes[0]);
+ Os.close(pipes[1]);
return progress;
}