diff options
author | midipix <writeonce@midipix.org> | 2016-12-07 23:29:58 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-08 16:32:31 -0500 |
commit | 8076b5e6f85667916a4ed50a191c4caef8da25b6 (patch) | |
tree | b6fbaafa91fcc9437f7ec5a26c5d224c112af67e | |
parent | 6fea2560943ee0d7f3195d67a6115b9058273fdc (diff) | |
download | ntapi-8076b5e6f85667916a4ed50a191c4caef8da25b6.tar.bz2 ntapi-8076b5e6f85667916a4ed50a191c4caef8da25b6.tar.xz |
__ntapi_tt_open_physical_parent_directory(): fix device root dir detection.
-rw-r--r-- | src/fs/ntapi_tt_open_physical_parent_directory.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/fs/ntapi_tt_open_physical_parent_directory.c b/src/fs/ntapi_tt_open_physical_parent_directory.c index e80a21a..d28eb1b 100644 --- a/src/fs/ntapi_tt_open_physical_parent_directory.c +++ b/src/fs/ntapi_tt_open_physical_parent_directory.c @@ -21,6 +21,7 @@ int32_t __stdcall __ntapi_tt_open_physical_parent_directory( nt_oa oa; nt_iosb iosb; wchar16_t * wch; + wchar16_t * root; nt_unicode_string * path; uint32_t len; @@ -35,17 +36,33 @@ int32_t __stdcall __ntapi_tt_open_physical_parent_directory( buffer_size, &len))) return status; - else if (len == sizeof(nt_unicode_string)) + + /* integrity */ + if (len == sizeof(nt_unicode_string)) return NT_STATUS_BAD_FILE_TYPE; - wch = path->buffer + (path->strlen / sizeof(uint16_t)); + /* device root directory */ + root = path->buffer; + wch = path->buffer + (path->strlen / sizeof(uint16_t)); + - for (; (wch > path->buffer) && (wch[-1] != '\\'); wch--) - (void)0; + if ((root[0] != '\\') + || (root[1] != 'D') || (root[2] != 'e') + || (root[3] != 'v') || (root[4] != 'i') + || (root[5] != 'c') || (root[6] != 'e') + || (root[7] != '\\')) + return NT_STATUS_INTERNAL_ERROR; - if (wch == path->buffer) + for (root=&root[8]; (root<wch) && (*root!='\\'); ) + root++; + + if ((uint16_t)((++root - path->buffer) * sizeof(uint16_t)) == path->strlen) return NT_STATUS_MORE_PROCESSING_REQUIRED; + /* physical parent directory path */ + for (; (wch>root) && (wch[-1]!='\\'); ) + wch--; + path->strlen = sizeof(uint16_t) * (uint16_t)(wch-path->buffer); path->maxlen = 0; |