From 4233e4d661e3beb8e4ecb59e4a4c0ed3d9df69b7 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 9 Jun 2015 08:55:44 -0400 Subject: [PATCH] Windows: AFSRetrieveFileAttributes no parent path Modify AFSRetrieveFileAttributes() to handle the case of a ParentPathName with a Length == 0. In such a case the introduction of a path separator would result in the construction of an absolute path when a relative path is required. Change-Id: I2e633b22992b0aee914927a451bb146fc57110e8 Reviewed-on: http://gerrit.openafs.org/11889 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index 2594416..5ad8fe6 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -5778,22 +5778,26 @@ AFSRetrieveFileAttributes( IN AFSDirectoryCB *ParentDirectoryCB, RtlZeroMemory( uniFullPathName.Buffer, uniFullPathName.MaximumLength); - RtlCopyMemory( uniFullPathName.Buffer, - ParentPathName->Buffer, - ParentPathName->Length); + if ( ParentPathName->Length > 0) + { - uniFullPathName.Length = ParentPathName->Length; + RtlCopyMemory( uniFullPathName.Buffer, + ParentPathName->Buffer, + ParentPathName->Length); - if( uniFullPathName.Buffer[ (uniFullPathName.Length/sizeof( WCHAR)) - 1] != L'\\' && - DirectoryCB->NameInformation.TargetName.Buffer[ 0] != L'\\') - { + uniFullPathName.Length = ParentPathName->Length; + + if( uniFullPathName.Buffer[ (uniFullPathName.Length/sizeof( WCHAR)) - 1] != L'\\' && + DirectoryCB->NameInformation.TargetName.Buffer[ 0] != L'\\') + { - uniFullPathName.Buffer[ uniFullPathName.Length/sizeof( WCHAR)] = L'\\'; + uniFullPathName.Buffer[ uniFullPathName.Length/sizeof( WCHAR)] = L'\\'; - uniFullPathName.Length += sizeof( WCHAR); - } + uniFullPathName.Length += sizeof( WCHAR); + } + } - RtlCopyMemory( &uniFullPathName.Buffer[ uniFullPathName.Length/sizeof( WCHAR)], + RtlCopyMemory( &uniFullPathName.Buffer[ uniFullPathName.Length/sizeof( WCHAR)], DirectoryCB->NameInformation.TargetName.Buffer, DirectoryCB->NameInformation.TargetName.Length); -- 1.9.4