Skip to content

Commit

Permalink
Ensure path is set for rmdir to prevent accidents (Fixes #756)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen van Erp <[email protected]>
  • Loading branch information
hierynomus committed May 8, 2023
1 parent 0b926eb commit 350c73e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/hierynomus/smbj/share/DiskShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ public boolean isSuccess(long statusCode) {
* Remove the directory at the given path.
*/
public void rmdir(String path, boolean recursive) throws SMBApiException {
if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("rmdir: path should be non-null and non-empty");
}

if (recursive) {
List<FileIdBothDirectoryInformation> list = list(path);
for (FileIdBothDirectoryInformation fi : list) {
Expand Down

0 comments on commit 350c73e

Please sign in to comment.