-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- FIX: Fixed potential security vulnerability that allows directory t…
…raversal. - FIX: Fixed potential security vulnerability that allows SQL injection.
- Loading branch information
1 parent
39535b9
commit 7ebc080
Showing
8 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package jhi.germinate.server.util; | ||
|
||
import java.io.*; | ||
|
||
public class FileUtils | ||
{ | ||
/** | ||
* Checks, whether the child directory is a subdirectory of the base | ||
* directory. | ||
* | ||
* @param base the base directory. | ||
* @param child the suspected child directory. | ||
* @return true, if the child is a subdirectory of the base directory. | ||
* @throws IOException if an IOError occured during the test. | ||
*/ | ||
public static boolean isSubDirectory(File base, File child) | ||
{ | ||
try | ||
{ | ||
base = base.getCanonicalFile(); | ||
child = child.getCanonicalFile(); | ||
} | ||
catch (IOException e) | ||
{ | ||
return false; | ||
} | ||
|
||
File parentFile = child; | ||
while (parentFile != null) | ||
{ | ||
if (base.equals(parentFile)) | ||
{ | ||
return true; | ||
} | ||
parentFile = parentFile.getParentFile(); | ||
} | ||
return false; | ||
} | ||
} |