@@ -352,12 +352,12 @@ static void unzip(InputStream fis, Path target) {
352352 // Iterate through zip entries
353353 while ((entry = zais .getNextEntry ()) != null ) {
354354
355- // Prevent path traversal attacks
356- Path outputPath = target .resolve (entry .getName ()).normalize ();
357-
358355 // Check if the entry is outside the target directory
359356 ensureSafeEntry (entry , target );
360357
358+ // Prevent path traversal attacks
359+ Path outputPath = target .resolve (entry .getName ()).normalize ();
360+
361361 if (entry .isDirectory ()) {
362362 LOG .debug ("Extracting directory: {}" , entry .getName ());
363363 Files .createDirectories (outputPath );
@@ -403,12 +403,12 @@ public static void untar(InputStream fis, Path target) {
403403 // Iterate through tar entries
404404 while ((entry = tais .getNextEntry ()) != null ) {
405405
406- // Prevent path traversal attacks
407- Path outputPath = target .resolve (entry .getName ()).normalize ();
408-
409406 // Check if the entry is outside the target directory
410407 ensureSafeEntry (entry , target );
411408
409+ // Prevent path traversal attacks
410+ Path outputPath = target .resolve (entry .getName ()).normalize ();
411+
412412 LOG .trace ("Extracting entry: {}" , entry .getName ());
413413
414414 if (entry .isDirectory ()) {
0 commit comments