File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/testing Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -404,8 +404,13 @@ private Path downloadEmulator() throws IOException {
404404 log .fine ("Unzipping emulator" );
405405 }
406406 ZipEntry entry = zipIn .getNextEntry ();
407- while (entry != null ) {
408- File filePath = new File (emulatorPath .toFile (), entry .getName ());
407+ while (entry != null ) {
408+ File filePath = new File (emulatorFolder , entry .getName ());
409+ String canonicalEmulatorFolderPath = emulatorFolder .getCanonicalPath ();
410+ String canonicalFilePath = filePath .getCanonicalPath ();
411+ if (!canonicalFilePath .startsWith (canonicalEmulatorFolderPath + File .separator )) {
412+ throw new IllegalStateException ("Entry is outside of the target dir: " + entry .getName ());
413+ }
409414 if (!entry .isDirectory ()) {
410415 extractFile (zipIn , filePath );
411416 } else {
You can’t perform that action at this time.
0 commit comments