martin-g commented on a change in pull request #35946:
URL: https://github.com/apache/spark/pull/35946#discussion_r832986477



##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -600,10 +600,30 @@ private[spark] object Utils extends Logging {
     if (lowerSrc.endsWith(".jar")) {
       RunJar.unJar(source, dest, RunJar.MATCH_ANY)
     } else if (lowerSrc.endsWith(".zip")) {
+      // TODO(SPARK-37677): should keep file permissions. Java implementation 
doesn't.
       FileUtil.unZip(source, dest)
-    } else if (
-      lowerSrc.endsWith(".tar.gz") || lowerSrc.endsWith(".tgz") || 
lowerSrc.endsWith(".tar")) {
+    } else if (lowerSrc.endsWith(".tar.gz") || lowerSrc.endsWith(".tgz")) {
       FileUtil.unTar(source, dest)
+    } else if (lowerSrc.endsWith(".tar")) {
+      // The codes below was copied from `FileUtil.unTar` but uses Java-based 
implementation
+      // to work around a security issue, see also SPARK-38631.
+      // TODO(SPARK-38632): should keep file permissions. Java implementation 
doesn't.
+      if (!dest.mkdirs && !dest.isDirectory) {
+        throw new IOException(s"Mkdirs failed to create $dest")
+      } else {
+        try {
+          // Should not fail because all Hadoop 2.1+ Haddop releases (from 
HADOOP-9264)

Review comment:
       ```suggestion
             // Should not fail because all Hadoop 2.1+ Hadoop releases (from 
HADOOP-9264)
   ```

##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -600,10 +600,30 @@ private[spark] object Utils extends Logging {
     if (lowerSrc.endsWith(".jar")) {
       RunJar.unJar(source, dest, RunJar.MATCH_ANY)
     } else if (lowerSrc.endsWith(".zip")) {
+      // TODO(SPARK-37677): should keep file permissions. Java implementation 
doesn't.
       FileUtil.unZip(source, dest)
-    } else if (
-      lowerSrc.endsWith(".tar.gz") || lowerSrc.endsWith(".tgz") || 
lowerSrc.endsWith(".tar")) {
+    } else if (lowerSrc.endsWith(".tar.gz") || lowerSrc.endsWith(".tgz")) {
       FileUtil.unTar(source, dest)
+    } else if (lowerSrc.endsWith(".tar")) {
+      // The codes below was copied from `FileUtil.unTar` but uses Java-based 
implementation
+      // to work around a security issue, see also SPARK-38631.
+      // TODO(SPARK-38632): should keep file permissions. Java implementation 
doesn't.
+      if (!dest.mkdirs && !dest.isDirectory) {
+        throw new IOException(s"Mkdirs failed to create $dest")
+      } else {
+        try {
+          // Should not fail because all Hadoop 2.1+ Haddop releases (from 
HADOOP-9264)
+          // has 'unTarUsingJava'.

Review comment:
       ```suggestion
             // have 'unTarUsingJava'.
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to