Mageia Bugzilla – Attachment 10632 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 creating a zip entry
Zipup.java (text/plain), 1.27 KB, created by
Brian Rockwell
on 2019-01-03 01:37:42 CET
(
hide
)
Description:
java code for creating a zip entry
Filename:
MIME Type:
Creator:
Brian Rockwell
Created:
2019-01-03 01:37:42 CET
Size:
1.27 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.OutputStream; > >import org.apache.commons.compress.archivers.ArchiveException; >import org.apache.commons.compress.archivers.ArchiveOutputStream; >import org.apache.commons.compress.archivers.ArchiveStreamFactory; >import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; >import org.apache.commons.compress.utils.IOUtils; > >public class Zipup { > > public static void main(String[] args) { > if (args.length < 2) { > System.out.println("Error: format is Zipup <uncompressed file> <zip file name>"); > System.exit(100); > } > > File input = new File(args[0].toString()); > File output = new File(args[1].toString()); > > > OutputStream out = null; > try { > out = new FileOutputStream(output); > } catch (FileNotFoundException e) { > e.printStackTrace(); > } > ArchiveOutputStream os = null; > try { > os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out); > os.putArchiveEntry(new ZipArchiveEntry(input.getName())); > IOUtils.copy(new FileInputStream(input), os); > os.closeArchiveEntry(); > os.close(); > } catch (ArchiveException | 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.OutputStream; import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveOutputStream; import org.apache.commons.compress.archivers.ArchiveStreamFactory; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.utils.IOUtils; public class Zipup { public static void main(String[] args) { if (args.length < 2) { System.out.println("Error: format is Zipup <uncompressed file> <zip file name>"); System.exit(100); } File input = new File(args[0].toString()); File output = new File(args[1].toString()); OutputStream out = null; try { out = new FileOutputStream(output); } catch (FileNotFoundException e) { e.printStackTrace(); } ArchiveOutputStream os = null; try { os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out); os.putArchiveEntry(new ZipArchiveEntry(input.getName())); IOUtils.copy(new FileInputStream(input), os); os.closeArchiveEntry(); os.close(); } catch (ArchiveException | IOException e) { e.printStackTrace(); } } }
View Attachment As Raw
Actions:
View
Attachments on
bug 22787
: 10632 |
10633