Skip to content

Commit

Permalink
Use the hostname part of the TargetHint for DFS step 9 (fixes \#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Jun 28, 2022
1 parent 3e454de commit 7837337
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/main/java/com/hierynomus/msdfsc/DFSPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ public List<String> getPathComponents() {
}

public DFSPath replacePrefix(String prefixToReplace, String target) {
return replacePrefix(prefixToReplace, splitPath(target));
}

public DFSPath replacePrefix(String prefixToReplace, DFSPath target) {
return replacePrefix(prefixToReplace, target.getPathComponents());
}

private DFSPath replacePrefix(String prefixToReplace, List<String> targetComponents) {
List<String> componentsToReplace = splitPath(prefixToReplace);
List<String> replacedComponents = new ArrayList<>();
replacedComponents.addAll(splitPath(target));
replacedComponents.addAll(targetComponents);
for (int i = componentsToReplace.size(); i < pathComponents.size(); i++) {
replacedComponents.add(pathComponents.get(i));
}
return new DFSPath(replacedComponents);

}

public boolean hasOnlyOnePathComponent() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/hierynomus/msdfsc/ReferralCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public class ReferralCache {
private ReferralCacheNode cacheRoot = new ReferralCacheNode("<root>");

public static class TargetSetEntry {
final String targetPath;
final DFSPath targetPath;
final boolean targetSetBoundary;

public TargetSetEntry(String targetPath, boolean targetSetBoundary) {
this.targetPath = targetPath;
this.targetPath = new DFSPath(targetPath);
this.targetSetBoundary = targetSetBoundary;
}

public String getTargetPath() {
public DFSPath getTargetPath() {
return targetPath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private <T> T step9(Session session, ResolveState<T> state, ReferralCache.Referr
referralCache.clear(state.path);
return step1(session, state);
}
ReferralResult result = sendDfsReferralRequest(DfsRequestType.LINK, rootReferralCacheEntry.getTargetHint().getTargetPath(), session, state.path);
ReferralResult result = sendDfsReferralRequest(DfsRequestType.LINK, rootReferralCacheEntry.getTargetHint().getTargetPath().getPathComponents().get(0), session, state.path);
if (!NtStatus.isSuccess(result.status)) {
return step14(session, state, result);
}
Expand Down

0 comments on commit 7837337

Please sign in to comment.