From cf35364efabc0c8dcf1802b4c287cc991730fd06 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 2 Jun 2025 20:22:50 +0200 Subject: [PATCH] [channels,drive] fix file rename length checks --- channels/drive/client/drive_file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 3d621a154..3787bc821 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -806,9 +806,9 @@ static BOOL drive_file_set_rename_information(DRIVE_FILE* file, UINT32 Length, w WINPR_ASSERT(file); const uint32_t expect = 6; - if (Length != expect) + if (Length < expect) { - WLog_WARN(TAG, "Unexpected Length=%" PRIu32 ", expected %" PRIu32, Length, expect); + WLog_WARN(TAG, "Unexpected Length=%" PRIu32 ", expected at least %" PRIu32, Length, expect); return FALSE; } @@ -817,8 +817,12 @@ static BOOL drive_file_set_rename_information(DRIVE_FILE* file, UINT32 Length, w Stream_Seek_UINT8(input); /* RootDirectory */ const uint32_t FileNameLength = Stream_Get_UINT32(input); - if (!Stream_CheckAndLogRequiredLength(TAG, input, FileNameLength)) + if (Length != expect + FileNameLength) + { + WLog_WARN(TAG, "Unexpected Length=%" PRIu32 ", expected %" PRIu32, Length, + expect + FileNameLength); return FALSE; + } WCHAR* fullpath = drive_file_combine_fullpath(file->basepath, Stream_ConstPointer(input), FileNameLength / sizeof(WCHAR));