From 46060275f1576cbf4b3601d50485d81d969c7a43 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 11 May 2015 13:12:30 +0300 Subject: nt_path_converter: logging & \0-termination --- src/nt_path_converter/device.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nt_path_converter') diff --git a/src/nt_path_converter/device.c b/src/nt_path_converter/device.c index 602a7e5..fbffd27 100644 --- a/src/nt_path_converter/device.c +++ b/src/nt_path_converter/device.c @@ -35,20 +35,27 @@ static NTSTATUS handle_convert_nt_path(void *in_buf, UNICODE_STRING uUnresolved, uResolved; NTSTATUS status = STATUS_SUCCESS; + DbgPrint("nt_path_converter: unresolved path: %ws\n", (WCHAR *) in_buf); + DbgPrint("nt_path_converter: unresolved size: %lu\n", in_buf_size); + RtlInitUnicodeString(&uUnresolved, (WCHAR *) in_buf); status = nt2dos(&uResolved, &uUnresolved); if (!NT_SUCCESS(status)) return status; - *nbwritten = uResolved.Length; + *nbwritten = uResolved.Length + sizeof(WCHAR); + + DbgPrint("nt_path_converter: resolved path: %wZ\n", &uResolved); + DbgPrint("nt_path_converter: resolved size: %Iu\n", *nbwritten); - if (out_buf_size < uResolved.Length) + if (out_buf_size < *nbwritten) { status = STATUS_BUFFER_OVERFLOW; goto FREE_RESOLVED; } + RtlFillMemory(out_buf, *nbwritten, L'\0'); RtlCopyMemory(out_buf, uResolved.Buffer, uResolved.Length); FREE_RESOLVED: -- cgit v1.2.3