Code RoomZip entry path not validated
HardPrep Room Coding #1664

Zip entry path not validated

Code reviewCode quality & reviewSenior–Staff~30 min

Review this Java archive-extraction utility.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1void unzip(InputStream in, File destDir) throws IOException {
2 try (ZipInputStream zis = new ZipInputStream(in)) {
3 ZipEntry e;
4 while ((e = zis.getNextEntry()) != null) {
5 File out = new File(destDir, e.getName());
6 out.getParentFile().mkdirs();
7 try (FileOutputStream fos = new FileOutputStream(out)) {
8 byte[] buf = new byte[8192];
9 int n;
10 while ((n = zis.read(buf)) != -1) fos.write(buf, 0, n);
11 }
12 }
13 }
14}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.