Merge branch 'issue-2251' of https://github.com/chris-sharl/Apktool into chris-sharl-issue-2251

This commit is contained in:
Connor Tumbleson 2020-04-11 06:43:54 -04:00
commit d4b2314e26
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -16,15 +16,21 @@
*/ */
package brut.util; package brut.util;
import brut.common.BrutException; import org.apache.commons.io.IOUtils;
import java.io.*; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.io.IOUtils; import brut.common.BrutException;
/** /**
* @author Ryszard Wiśniewski <brut.alll@gmail.com> * @author Ryszard Wiśniewski <brut.alll@gmail.com>
@ -79,7 +85,14 @@ abstract public class Jar {
if (in == null) { if (in == null) {
throw new FileNotFoundException(resourcePath); throw new FileNotFoundException(resourcePath);
} }
File fileOut = File.createTempFile(tmpPrefix, null); long n = ThreadLocalRandom.current().nextLong();
if (n == Long.MIN_VALUE) {
n = 0; // corner case
} else {
n = Math.abs(n);
}
String suffix = Long.toString(n) + ".tmp";
File fileOut = File.createTempFile(tmpPrefix, suffix);
fileOut.deleteOnExit(); fileOut.deleteOnExit();
OutputStream out = new FileOutputStream(fileOut); OutputStream out = new FileOutputStream(fileOut);
IOUtils.copy(in, out); IOUtils.copy(in, out);