mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 13:57:46 +01:00
refactor: support more random suffix to prevent multi-thread crash
This commit is contained in:
parent
d4b2314e26
commit
44a2e87f81
@ -85,19 +85,16 @@ abstract public class Jar {
|
|||||||
if (in == null) {
|
if (in == null) {
|
||||||
throw new FileNotFoundException(resourcePath);
|
throw new FileNotFoundException(resourcePath);
|
||||||
}
|
}
|
||||||
long n = ThreadLocalRandom.current().nextLong();
|
long suffix = ThreadLocalRandom.current().nextLong();
|
||||||
if (n == Long.MIN_VALUE) {
|
suffix = suffix == Long.MIN_VALUE ? 0 : Math.abs(suffix);
|
||||||
n = 0; // corner case
|
File fileOut = File.createTempFile(tmpPrefix, suffix + ".tmp");
|
||||||
} 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);
|
||||||
in.close();
|
in.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
return fileOut;
|
return fileOut;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new BrutException("Could not extract resource: " + resourcePath, ex);
|
throw new BrutException("Could not extract resource: " + resourcePath, ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user