diff options
Diffstat (limited to 'src')
-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; |