Fixed path NULL checks.
authorArmin Novak <armin.novak@thincast.com>
Tue, 19 Nov 2019 09:48:25 +0000 (10:48 +0100)
committerArmin Novak <armin.novak@thincast.com>
Tue, 19 Nov 2019 09:48:25 +0000 (10:48 +0100)
channels/drive/client/drive_file.c
channels/drive/client/drive_main.c

index 8f03fd8..cefa340 100644 (file)
@@ -94,7 +94,7 @@ static WCHAR* drive_file_combine_fullpath(const WCHAR* base_path, const WCHAR* p
        WCHAR* fullpath;
        size_t base_path_length;
 
-       if (!base_path || !path)
+       if (!base_path || (!path && (PathLength > 0)))
                return NULL;
 
        base_path_length = _wcslen(base_path) * 2;
@@ -338,7 +338,7 @@ DRIVE_FILE* drive_file_new(const WCHAR* base_path, const WCHAR* path, UINT32 Pat
 {
        DRIVE_FILE* file;
 
-       if (!base_path || !path)
+       if (!base_path || (!path && (PathLength > 0)))
                return NULL;
 
        file = (DRIVE_FILE*)calloc(1, sizeof(DRIVE_FILE));
index 65e1317..494764a 100644 (file)
@@ -163,7 +163,7 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp)
        UINT32 CreateOptions;
        UINT32 PathLength;
        UINT64 allocationSize;
-       const WCHAR* path = NULL;
+       const WCHAR* path;
 
        if (!drive || !irp || !irp->devman || !irp->Complete)
                return ERROR_INVALID_PARAMETER;
@@ -182,8 +182,7 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp)
        if (Stream_GetRemainingLength(irp->input) < PathLength)
                return ERROR_INVALID_DATA;
 
-       if (PathLength > 0)
-               path = (const WCHAR*)Stream_Pointer(irp->input);
+       path = (const WCHAR*)Stream_Pointer(irp->input);
        FileId = irp->devman->id_sequence++;
        file = drive_file_new(drive->path, path, PathLength, FileId, DesiredAccess, CreateDisposition,
                              CreateOptions, FileAttributes, SharedAccess);