Mageia Bugzilla – Attachment 10633 Details for
Bug 22787
apache-commons-compress new security issues CVE-2018-1324 and CVE-2018-11771
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
java code for extracting a zip entry
Zipextract.java (text/plain), 1.39 KB, created by
Brian Rockwell
on 2019-01-03 01:42:08 CET
(
hide
)
Description:
java code for extracting a zip entry
Filename:
MIME Type:
Creator:
Brian Rockwell
Created:
2019-01-03 01:42:08 CET
Size:
1.39 KB
patch
obsolete
>import java.io.File; >import java.io.FileInputStream; >import java.io.FileNotFoundException; >import java.io.FileOutputStream; >import java.io.IOException; >import java.io.InputStream; >import java.io.OutputStream; > >import org.apache.commons.compress.archivers.ArchiveException; >import org.apache.commons.compress.archivers.ArchiveInputStream; >import org.apache.commons.compress.archivers.ArchiveStreamFactory; >import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; >import org.apache.commons.compress.utils.IOUtils; > >public class Zipextract { > > public static void main(String[] args) { > if (args.length < 2) { > System.out.println("Error: format is Zipextract <zip file> <extract location>"); > System.exit(100); > } > > File input = new File(args[0].toString()); > String output = args[1].toString(); > > InputStream is=null; > try { > is = new FileInputStream(input); > } catch (FileNotFoundException e) { > e.printStackTrace(); > System.exit(200); > } > > ArchiveInputStream in=null; > try { > in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is); > ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry(); > OutputStream out = new FileOutputStream(new File(output, entry.getName())); > IOUtils.copy(in, out); > out.close(); > in.close(); > } catch (ArchiveException e) { > e.printStackTrace(); > } catch (IOException e) { > e.printStackTrace(); > } > > > } > >}
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveInputStream; import org.apache.commons.compress.archivers.ArchiveStreamFactory; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.utils.IOUtils; public class Zipextract { public static void main(String[] args) { if (args.length < 2) { System.out.println("Error: format is Zipextract <zip file> <extract location>"); System.exit(100); } File input = new File(args[0].toString()); String output = args[1].toString(); InputStream is=null; try { is = new FileInputStream(input); } catch (FileNotFoundException e) { e.printStackTrace(); System.exit(200); } ArchiveInputStream in=null; try { in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is); ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry(); OutputStream out = new FileOutputStream(new File(output, entry.getName())); IOUtils.copy(in, out); out.close(); in.close(); } catch (ArchiveException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
View Attachment As Raw
Actions:
View
Attachments on
bug 22787
:
10632
| 10633